Hi Experts,

When issuing updates in mysql (in the console window), mysql will tell
you if any rows matched and how many rows were updated (see below).  I
know how to get number of rows udpated using mysql_affected_rows(), but is
there any
way to get the number of rows matched?  I want to find out, when rows
updated = 0, if there were no updates because the row wasn't found
(rows matched will = 0) or because the update would not have changed
any data (rows matched = 1).

mysql> select * from test;
+------+------+
| roll | s    |
+------+------+
|    1 | new  |
+------+------+
1 row in set (0.00 sec)

mysql> update test set roll = 1, s = 'new' where roll = 1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0

mysql> update test set roll = 1, s = 'new' where roll = 17;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0  Changed: 0  Warnings: 0

mysql> update test set roll = 1, s = 'neww' where roll = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

--
Cheers,
Rajan

Reply via email to