Re: MySQL: Return Number of Matched Rows
| From: | Shawn McKenzie | Date: | Fri, 26 Mar 2010 15:15:13 +0000 |
| Subject: | Re: MySQL: Return Number of Matched Rows | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303513@lists.php.net to get a copy of this message | ||
James Colannino wrote:
> Hey everyone,
>
> I have a question. If I do a mysql query that updates a column in a row
> to the same value, I get 0 rows affected. However, I also get 1 or more
> matched rows. Is there a way that I can return the number of matched
> rows, rather than the number of rows affected?
>
> I'm trying to get something done with as few SQL queries as possible.
> Thanks!
>
> James
If it works in your situation you can use REPLACE instead of UPDATE and
the mysql_affected_rows() should work. You may need to divide this
number by 2 as I think it counts the deletes and inserts.
--
Thanks!
-Shawn
http://www.spidean.com