Francisco Ivan Anton Prieto <[EMAIL PROTECTED]> wrote:
> 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???
Yup, you can retrieve rows before UPDATE.
> Is there a better way?
> I use SELECT...FOR UPDATE and it seems does not work.
SELECT .. FOR UPDATE isn't that you are looking for.
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Egor Egorov
/ /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net
<___/ www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]