, ,

I use MySQL and MS SQL at work and have never used PostgreSQL. So it was a nice learning about the evaluation of the update queries in MySQL and PostgreSQL today..

Seems that UPDATE table SET X=Y, Y=X is enough in PostgreSQL to swap two columns !! It just picks up the old values of X and Y when evaluating the RHS of these assignments and hence the swap works fine. On the other hand, the same query will not do good in MySQL because of the left-to-right evaluation order followed by MySQL.