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

拼搏现实的明天。 2022-08-26 11:27 120阅读 0赞

先看例子在解释表 proxy

![Image 1][]

有这样一个表,我们想帅选出 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)

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,120人围观)

还没有评论,来说两句吧...

相关阅读