mysql sql语法问题(2)

来源:互联网 发布:双轨制直销系统 php 编辑:程序博客网 时间:2024/06/06 12:25

   select * from users where userId not in ( select userId from users order by userId limit 0,2)

   这条语句在我现在这个版本的MySQL上执行不了,错误信息提示是:
ERROR 1235 (42000): This version of MySQL doesn't yet support 'LIMIT & IN/ALL/AN
Y/SOME subquery'

意思是:这版本的 MySQL 不支持使用 LIMIT 子句的 IN/ALL/ANY/SOME 子查詢,即是支持非 IN/ALL/ANY/SOME 子查詢的 LIMIT 子查詢
需要将其转换成如下语句即可执行(多加一层):

 select * from users where userId not in(select t.userId from(select * from users order by userId limit 0,2)as t);

 

可参考:http://apps.hi.baidu.com/share/detail/3727629

 

在mysql中已验证如下语句可执行:

1.select * from users order by userId limit 0,5

2. select * from user where userId ( not ) between 1 and 3

3. select * from users where username not in (select username from users where username='admin');

 

原创粉丝点击