I have a select like this:
SELECT field1, field2, field3
FROM table WHERE field1= 5 AND field_flag =1
GROUP BY field1, field2, field3 limit 1000;
I want to update field_flag for the resulting rows. How can I do that in MySQL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Do you mean that you want to update table where field1, field2, and field3 are in the set returned by your select statement ?
eg.
Note that the update might update many more than 1000 rows.
A temporary table could be used too:
This has the advantage that temptab can be used later, and also that indexes can be added to speed up the update: