Mysql:Error Code 1235,This version of MySQL doesn't
发布时间:2020-12-12 02:24:55 所属栏目:MySql教程 来源:网络整理
导读:执行sql语句遇到错误: [Err]?1235?-?This?version?of?MySQL?doesn't?yet?support?'LIMIT??IN/ALL/ANY/SOME?subquery' 原sql语句: SELECT?id,friend_id,sender_id,obj_key,comment_id,content,ctime?from?msg?where??id?in?(SELECT?MAX(id)?as?id?FROM?msg?
执行sql语句遇到错误: [Err]?1235?-?This?version?of?MySQL?doesn't?yet?support?'LIMIT?&?IN/ALL/ANY/SOME?subquery' 原sql语句: SELECT?id,friend_id,sender_id,obj_key,comment_id,content,ctime?from?msg? where?? id?in?(SELECT?MAX(id)?as?id?FROM?msg?WHERE?user_id?=?312?and?status?!=3??GROUP?BY?obj_key,comment_id?ORDER?BY?id?DESC?LIMIT?10) 结果查询发现是:在MySQL中子查询是不能使用LIMIT 解决办法: 比如这样的语句是不能正确执行的。? select?*?from?table?where?id?in?(select?id?from?table?limit?12); 第一种方法:只要你再加一层就行。如:? select?*?from?table?where?id?in?(select?t.id?from?(select?*?from?table?limit?12)?as?t) 第二种方法: select?*?from?(select?id?from?table?limit?12)?as?t; 第三种方法:使用inner join ....? on .... select?t.id?from?table?as?t? inner?join (select?id?from?table?limit?12)?as?t2 on?t.id=t2.id 建议使用inner join,因为通常db引擎会将where?解析为join 参考:http://blog.chinaunix.net/uid-22414998-id-2945656.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |