在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子查询的问题。
本文介绍了在 MySQL 4.1 版本中如何解决子查询不能使用 LIMIT 的限制。通过增加一层子查询,可以有效地绕过这个限制,实现预期的功能。
1486

被折叠的 条评论
为什么被折叠?



