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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -