Is this the right way to optimize MySQL Query?

$sql="update users_contain set wood_max = (Select building_production from building_level where merge_id=$subPrimaryKey and empire_id=$user_empireID) , iron_max = wood_max, clay_max = wood_max where user_id = $user_id"; 

Now the question is.

wood_max will always be updated first than iron_max and clay_max. is it safe to use this method? I do not want to use the internal query to update iron_max and clay_max when I know that it has the same value for all three fields.

+4
source share
1 answer

According to this documentation, your UPDATE statement works the way you want: http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-update.html

Check it out, but I think everything is in order.

+2
source

All Articles