mysql 子查詢中 使用 limit


 

如果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 subquery' #

解決辦法:

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM