mysql update column=column+1返回0

izj3ouym  于 2021-06-23  发布在  Mysql
关注(0)|答案(1)|浏览(353)

sql语句:

update table set column = column + 1 where id = #{id}

为什么这个sql可以返回0我相信它总是会返回1

qhhrdooz

qhhrdooz1#

我猜你说的是

Query OK, 0 rows affected (0.05 sec)

如果是,那么如果db table by supplied语句中没有更改,则返回“0”。
就你而言,

update table set column = column + 1 where id = #{id}

如果语句中的“0”表示为列“id”传递的参数与表中的任何记录都不匹配,因此db table中没有受影响的记录。

观察:

在update语句中,您说的“update table”没有反引号,这意味着我猜它将返回mysql错误,因为您使用了保留键。
或者你可以这样尝试:

update `table`

相关问题