日期:2014-05-16  浏览次数:20756 次

MySql中limit子查询的解决办法
在MySQL4.1中子查询是不能使用LIMIT的,手册中也明确指明 “This version of MySQL doesn’t yet support ‘LIMIT & IN/ALL/ANY/SOME subquery’ ”

这样的语句是不能正确执行的。
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)

ok这样就可以绕开limit子查询的问题。
原文地址:http://hi.baidu.com/%C5%DD%B0%C9%BA%C8%BE%C6/blog/item/df9b4d2dbadfe9e58a139937.html/cmtid/e35387178161795ff3de3297