哪个更好,先选择然后更新。或者更确切地说,像这样合而为一:
UPDATE items set status = 'NEW'
where
itemid in (1,2,3,4,5,6,7) AND
status = 'OLD' AND
9387487484 >= itemdate
哪个更好,先选择然后更新。或者更确切地说,像这样合而为一:
UPDATE items set status = 'NEW'
where
itemid in (1,2,3,4,5,6,7) AND
status = 'OLD' AND
9387487484 >= itemdate
语句可用的每个优化SELECT
都将在语句处理期间应用UPDATE
(如果我怀疑这是您所关心的)。因此,只需发出一个UPDATE
.
参考:http ://dev.mysql.com/doc/refman/5.5/en/update-speed.html