美文网首页
mysql子查询不支持limit问题解决

mysql子查询不支持limit问题解决

作者: 沙顺 | 来源:发表于2018-08-19 16:43 被阅读0次

如果sql语句中的子查询包含limit 

例如: select * from a where id in (select id from b limit 3) 

会报错:This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME

解决办法:

1、加一层子查询 

例如:select * from a where id in (select t.id from (select id from b limit 3 )as t) 

2、把限制条件放到from而非where子句中,就不必出现嵌套再嵌套。 

例如:select * from (select id from a limit 3) as foo

相关文章

网友评论

      本文标题:mysql子查询不支持limit问题解决

      本文链接:https://www.haomeiwen.com/subject/wlwciftx.html