开发者

LIMIT support in MySQL

I am trying to execute the开发者_如何转开发 following query.

update share set holder = 22 where SHARE_ID IN (select SHARE_ID from SHARE WHERE holder=1 LIMIT 10)

When I try to execute the above query I am getting this error

#1235 - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'


UPDATE  share
SET     holder = 22
WHERE   holder = 1
ORDER BY
        share_id
LIMIT 10

Due to the optimizer issues, LIMIT is not supported in the IN clause.


why don't you try

UPDATE share 
SET holder = 22 
WHERE holder=1 LIMIT 10

For more information, however, you can the read mysql doc. "Limit" and "order by" can't be used with a multiple table update query, which is not your case here.


Your error is that you are using IN and MySQL doesn't support that, so you need another way to work your query. What you might want to consider doing, if this is not a query you need often, is dumping the "IN query" to a table and then doing a join and checking against that.


The error message is telling you the problem, the query syntax you are trying to use is not supported by the version of MySQL that you are using.

You will need to re-think your query to work with the processes supported by your current MySQL Version.


mysql 5.5 yet not support the limit in the sub query

http://dev.mysql.com/doc/refman/5.5/en/subquery-errors.html

u need to fix your query

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜