amy_888 发表于 2016-10-20 07:12:45

This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery

  先看例子在解释表 proxy
http://mywebcode.iyunv.com/blog/

  有这样一个表,我们想帅选出 max_bid,排在前两为的所有数据。。。。即:这里最大的前两位为 500 ,200, 即:我们要帅选出max_bid 为500 和 200 的所有数据。
  一开始我的想法。
  select * from proxy where max_bid in (select max_bid from proxy p group by p.max_bid desc limit 2);
  用了这个语句之后就报This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery 这个错误。
  经过网上查找。
  select * from proxy where max_bid in (select price.max_bid from(select * from proxy p group by p.max_bid desc limit 2)as price);//正确

  

  
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'的意思是,这版本的 MySQL 不支持使用 LIMIT 子句的 IN/ALL/ANY/SOME 子查询,即是支持非 IN/ALL/ANY/SOME 子查询的 LIMIT 子查询。
也就是说,这样的语句是不能正确执行的。
select * from table where id in (select id from table limit 10)

但是,只要你再来一层就行。。如:
select * from table where id in (select t.id from (select * from table limit 10)as t)
页: [1]
查看完整版本: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery