views:

181

answers:

1
  $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 there is a question.

will wood_max will always be updated first than iron_max and clay_max. so it is safe to use this way?? i do not want to use inner query for updating the iron_max and clay_max when i know it has same value for all three fields..

+2  A: 

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

Test it to be sure, but I think you're fine.

Bernard
"This behavior differs from standard SQL." Scary.
Lee Reeves
Yeah, that is a bit scary, but since the OP specified MySQL as their database platform, they'll be fine. Care must be taken if supporting multiple database platforms though.
Bernard
Thanks! Your link is FINAL.. Like Final Classes..:)
Muhammad Irfan