这个MySQL语句怎么解释?

MySql 码拜 8年前 (2016-02-21) 887次浏览
下面这条SQL语句:
select * from article where id = 1 and (select 1 from (select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x)a);
1. 其中floor(rand(0)*2))x 后面的x是怎么解释?
2. 语句最后的a怎么解释?
解决方案

20

concat(version(),floor(rand(0)*2)将这个取别名叫x,你也可以叫其他的
select count(*),concat(version(),floor(rand(0)*2))x from information_schema.tables group by x
根据x分组,也可以说是根据concat(version(),floor(rand(0)*2))分组

5

 (select count(*),concat(version(),floor(rand(0)*2))  x
(select count(*), x from information_schema.tables group by x) a

15

引用 2 楼 pythonilove 的回复:

语句最后的a呢?

a  是这个查询数据集
select count(*), concat(version(),floor(rand(0)*2))x  from information_schema.tables group by x 的别名
也可以写成
(select count(*), concat(version(),floor(rand(0)*2))x  from information_schema.tables group by x) AS a


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明这个MySQL语句怎么解释?
喜欢 (0)
[1034331897@qq.com]
分享 (0)