Reputation: 13527
Which is better, doing a select first and then an update. Or rather all in one like this:
UPDATE items set status = 'NEW'
where
itemid in (1,2,3,4,5,6,7) AND
status = 'OLD' AND
9387487484 >= itemdate
Upvotes: 0
Views: 82
Reputation: 29759
Every optimisation available to a SELECT
statement will be applied during the processing of an UPDATE
statement (if, as I suspect, this is your concern). Therefore, just issue a single UPDATE
.
Reference: http://dev.mysql.com/doc/refman/5.5/en/update-speed.html
Upvotes: 3