mysql - Order of execution of SQL UPDATE while updating multiple values? -


what sequence in values (separated commas) updated?

$command = sprintf('update %s set rating = ((rating * rating_count + %f) / (rating_count + 1.0)) , rating_count=rating_count+1 id=%d', $table, $ratinggiven, $id)`; 

i want make sure that

rating = (rating * rating_count + %f) / (rating_count + 1.0) 

is executed before

rating_count=rating_count+1 

without firing 2 sql commands.

i not sure if update-value-statements executed in order in separated commas in mysql (or other db)?

i don't think matter update read current row , update upon based on existing values, , not ones in update.

so in both set operations, original value of rating_count used.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -