At 11:11 PM -0700 6/10/07, Ace wrote:
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).

Pass the CLIENT_FOUND_ROWS flag value to mysql_real_connect() when
you connect to the server.

http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html


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


--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to