mysql的update语句limit不知为什么出错

来源:百度知道 编辑:UC知道 时间:2024/05/27 08:12:18
update sina_ecms_xiazai set isgood='1' where firsttitle='1' order by id desc limit 8,1

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
update ***_ecms_xiazai set isgood='1' where firsttitle='1' order by id desc limit 8,1
我只想执行从第8条以后的一条信息,那怎么办呢
能不能用组合语句呢?我不太会,教我一下怎么组合

update 语句中的 limit 只能指定一个数,表示更新多少行后停止,不能跳过多少行再更新,你的语句要使用id作为条件进行操作,没有办法达到你的想法。

我没看代码但是你要是想修改第八行的数据,可以采用多表联合查询的方法,先查出 limit 8,1 将查询出第八行id,在通过第八行的id进行修改
updata 'table' set 'name'='name1' where id=t1.id1(
select 'id1' from 'table' limit 8,1
)as t1

order by id desc limit 只能用来查找即select,不能与update搭配使用。你需要重新设计。