且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有什么方法可以区分 0 受影响的 MYSQL 更新行的情况吗?

更新时间:2023-02-07 18:30:31

如果你只想要'匹配'的行数(不再需要'改变'的行数),你可以设置 CLIENT_FOUND_ROWS代码> 如此处所述:

if you only want the number of 'matched' rows (and no longer the number of 'changed' rows), you can set CLIENT_FOUND_ROWS as described here:

http://dev.mysql.com/doc/refman/5.5/en/mysql-affected-rows.html

对于 UPDATE 语句,默认情况下受影响的行值是实际更改的行数.如果您指定 CLIENT_FOUND_ROWS连接到 mysqld 时标记 mysql_real_connect(),受影响的行值是找到"的行数;也就是说,匹配WHERE 子句.

For UPDATE statements, the affected-rows value by default is the number of rows actually changed. If you specify the CLIENT_FOUND_ROWS flag to mysql_real_connect() when connecting to mysqld, the affected-rows value is the number of rows "found"; that is, matched by the WHERE clause.