文章讲述了在MySQL中尝试使用IN关键字结合LIMIT子句时遇到的1235错误,即不支持LIMIT&IN/ALL/ANY/SOMEsubquery。解决方案是将子查询封装到另一个查询中,避免IN和LIMIT在同一层次。通过创建一个新的子查询来获取TOP3用户ID,然后在外层查询中使用这些ID过滤用户。
SELECT * FROM `user` WHERE ( `user`.id ) IN ( SELECT article.user_id FROM article GROUP BY article.user_id ORDER BY COUNT( article.user_id ) DESC LIMIT 0, 3 )
即MySQL中in关键字不能和limit连用,即会报1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'的错误
要解决很简单,不让in关键字和limit关键字在一层上,把后面的子查询语句包起来,
SELECT * FROM `user` WHERE ( `user`.id ) IN ( SELECT a.user_id FROM ( SELECT article.user_id FROM article GROUP BY article.user_id ORDER BY COUNT( article.user_id ) DESC LIMIT 0, 3 ) AS a )
注意 是把后面查出来的数据当做一个新表,来多包一层,让in和limit没在一层。
标签:1235,support,SOME,LIMIT,user,MySQL,article,id,SELECT From: https://www.cnblogs.com/min225016/p/18673209