Ken Smith <[EMAIL PROTECTED]> writes:
> create table test (name char, a int, b int);
> insert into test values ('x', 1, 2);
> update test set a=3,b=a where name='x';
> select * from test;
> name | a | b
> ------+---+---
> x | 3 | 1
This is correct ...
> I am used to MySQL so I expected the following from the select
> statement.
> name | a | b
> ------+---+---
> x | 3 | 3
> Which behavior is the correct?
MySQL is evidently evaluating the assignments left-to-right, and using
the updated values of prior columns in subsequent expressions.
Unfortunately for MySQL, that is unquestionably a violation of the SQL
spec. I refer you to SQL92 section 3.10 <update statement: searched>,
General Rule 6:
6) The <value expression>s are effectively evaluated for each row
of T before updating any row of T.
There is no other way to read that except that the expressions are all
to be evaluated using the *old* values of the row.
regards, tom lane