栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在sqlite3 where子句中使用列别名

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在sqlite3 where子句中使用列别名

使用

SQLITE_DEBUG
启用了标志的sqlite3 :

sqlite> create table x (x1 integer);sqlite> insert into x values (1);sqlite> insert into x values (2);sqlite> insert into x values (3);sqlite> insert into x values (4);sqlite> insert into x values (5);sqlite> pragma vdbe_listing=1;VDBE Program Listing:   0 Expire0    0    0      00    1 Halt  0    0    0      00 sqlite> select x1*x1 as s from x where s>-10 and s>-9 and s>0 and s>-4 and s>2;VDBE Program Listing:   0 Trace 0    0    0      00    1 Integer        -10    1    0      00    2 Integer         -9    2    0      00    3 Integer          0    3    0      00    4 Integer         -4    4    0      00    5 Integer          2    5    0      00    6 Goto  0   26    0      00    7 OpenRead         0    3    0 1    00 x   8 Rewind0   24    0      00    9 Column0    0    7      00 x.x1  10 Multiply         7    7    6      00   11 Le    1   23    6      6A   12 Multiply         7    7    6      00   13 Le    2   23    6      6A   14 Multiply         7    7    6      00   15 Le    3   23    6      6A   16 Multiply         7    7    6      00   17 Le    4   23    6      6A   18 Multiply         7    7    6      00   19 Le    5   23    6      6A   20 Column0    0    6      00 x.x1  21 Multiply         6    6    9      00   22 ResultRow        9    1    0      00   23 Next  0    9    0      01   24 Close 0    0    0      00   25 Halt  0    0    0      00   26 Transaction      0    0    0      00   27 Verifycookie     0    4    0      00   28 TableLock        0    3    0 x    00   29 Goto  0    7    0      00 s   ----4   9   16  25  sqlite>

从上面的指令堆栈可以看出,行的循环(第8-23行)针对表中的每一行对子句中的每个表达式重复执行

Multiply
and
Le
命令
where

因此,要回答我自己的问题,sqlite引擎能够通过

select
在执行时替换列的别名来使用列别名
where



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/634926.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号