在supesite里面执行一个SQL语句: select * from supe_spaceitems where catid=98 and itemid not in(select itemid from supe_spaceitems where catid=98 and haveattach=1 order by itemid desc limit 1) order by itemid desc limit 3;
发现如下提示: #1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
原因:发现mysql不支持in子句的limit查询
于是,修改语法如下:select * from supe_spaceitems where catid=98 and itemid not in(select t.itemid from(select * from supe_spaceitems where catid=98 and haveattach=1 order by itemid desc limit 1) as t) order by itemid desc limit 3;
在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)
你说说,MySQL是不是很让人无语??
经本人测试使用,该方法不错!