84669 personnes étudient
152542 personnes étudient
20005 personnes étudient
5487 personnes étudient
7821 personnes étudient
359900 personnes étudient
3350 personnes étudient
180660 personnes étudient
48569 personnes étudient
18603 personnes étudient
40936 personnes étudient
1549 personnes étudient
1183 personnes étudient
32909 personnes étudient
比如SELECT a AS b WHRER b=1;
我这样使用会报错,说b不存在。
学习是最好的投资!
因为mysql底层跑SQL语句时:where 后的筛选条件在先, as B的别名在后。所以机器看到where 后的别名是不认的,所以会报说B不存在。
如果非要用B做筛选条件的话:解决方案:外边再嵌套一层。select * from(select A as B from table) t where t.B = XXX -- 任意的筛选条件
如果不嵌套,只能用A做筛选条件了
当然不存在,这个b只针对与a查询结果的一个别名 select a AS b FROM table where a = 1
select t.b from(
select a as B from table
) t
where t.b =xxxx
此时的B是可以直接在where中使用的
b是对查询结果a取的别名where里面肯定是不存在啊
因为mysql底层跑SQL语句时:where 后的筛选条件在先, as B的别名在后。
所以机器看到where 后的别名是不认的,所以会报说B不存在。
如果非要用B做筛选条件的话:
解决方案:外边再嵌套一层。
select * from
(
select A as B from table
) t
where t.B = XXX -- 任意的筛选条件
如果不嵌套,只能用A做筛选条件了
当然不存在,这个b只针对与a查询结果的一个别名
select a AS b FROM table where a = 1
select t.b from
(
select a as B from table
) t
where t.b =xxxx
此时的B是可以直接在where中使用的
b是对查询结果a取的别名where里面肯定是不存在啊