mysql 子查询不支持limit
mysql执行如下语句 :
SELECT * FROM `xxx_base_info` where yn =1 and xxx_keeper_id in (SELECT id FROM `user`where level>1 and yn =1 order by level desc limit 50)
MySQL 返回:
#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
解决方案:
1、加一层子查询搞定:
SELECT * FROM `xxx_base_info` where yn =1 and xxx_keeper_id in ( select aa.id from (SELECT id FROM `user`where level>1 and yn =1 order by level desc limit 50) aa)
2、另一个解决方案,如果子查询和主查询是同一张表的话,可以把限制条件放到FROM后,不放到where后也可以