UPDATE messages set test_read =1
WHERE userid='xyz'
ORDER BY date_added DESC
LIMIT 5, 5 ;
我正在尝试使用此查询使用限制更新一组 5 行,但 mysql 显示错误..下面的一个正在工作
I am trying to use this query to update a set of 5 rows using limit but mysql is showing an error..The one below is working
UPDATE messages set test_read =1
WHERE userid='xyz'
ORDER BY date_added DESC
LIMIT 5 ;
为什么第一个不起作用?
why is the first one not working?
如果你真的必须这样做,你可以使用这样的方法:
If you really must do it this way, you can use something like this:
UPDATE messages SET test_read=1
WHERE id IN (
SELECT id FROM (
SELECT id FROM messages
ORDER BY date_added DESC
LIMIT 5, 5
) tmp
);
这篇关于使用mysql中的限制更新多行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!