Suppose we have a table mytable
with columns id
, a
, b
and there is a row with values (123, 'foo', 'bar')
.
I perform this query:
UPDATE mytable SET b=a, a='boom' WHERE id=123
I'd expect the two assignments to be performed in the given order, and hence the resulting row to be (123, 'boom', 'foo')
, but is this guaranteed?
Or is the order of execution undefined and hence theoretically possible that the optimizer for whatever reason decides to execute them in reverse order, which would end up with (123, 'boom', 'boom')
?
MySQL documentation doesn't explicitly state that the assignments are executed in the order they appear in the query.