在Mysql中使用嵌套查詢,就是在子查詢中的select語句帶有limit。
比如這樣的語句是不能正確查詢的:
select * from tableA where id in(select id from tableB limit 0,1);
不然會報錯誤:This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
解決方法是在後面的子查詢中再嵌套一層(把子查詢當成一張表再查):
select * from tableA where id in(select t.id from (select id from tableB limit 0,1) as t );