mysql在子查询in中用了limit,然后报错:
[SQL] select distinct(p.id) poetryId,content poetryDesc,author poetryAnthor,l.backImg labelImg,p.fullContent flag,archaics,moods,scenes,hots,works,2 collectionType,l.archaicsImg,p.worksName from dd_poetry p join dd_label l on l.id = p.archaics where 1=1 and p.id in( select id from dd_poetry order by rand() limit 100 ) [Err] 1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
in (select id from table limit 100)的时候报错~~~~
解决办法:
在limit的外层在套一层:in (select id from (select id from table limit 100) as t)的时候报错~~~~
select distinct(p.id) poetryId,content poetryDesc,author poetryAnthor,l.backImg labelImg,p.fullContent flag,archaics,moods,scenes,hots,works,2 collectionType,l.archaicsImg,p.worksName from dd_poetry p join dd_label l on l.id = p.archaics where 1=1 and p.id in( select t.id from (select id from dd_poetry order by rand() limit 100) as t )
先随机100条再来查询