Egor Egorov wrote:

Francisco Ivan Anton Prieto <[EMAIL PROTECTED]> wrote:


I am crazy with a problem.

I would like to know the best method to SELECT affected rows after an UPDATE.




If you set column values to the new (different from current value), you can just use the same WHERE clause in the SELECT statement.






UPDATE table SET a=1 WHERE a=0 LIMIT 2;
SELECT * FROM table WHERE a=1 ->doesn't work because column a have rows with value '1' before UPDATE


I have the next idea :

query("LOCK TABLES table");
   // HERE RETRIEVE ROWS I WILL UPDATE
   result  = query(SELECT * FROM table WHERE a=0 LIMIT 2);
   // HERE I UPDATE ROWS
   query("UPDATE table SET a=1 WHERE WHERE a=0 LIMIT 2");
query("UNLOCK TABLES");

This would work fine???
Is there a better way?
I use SELECT...FOR UPDATE and it seems does not work.
I'll wait your comments.

Thanks for your time





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



Reply via email to