Re: swapping column values in update

2006-08-01 Thread Pete Harlan
On Wed, Aug 02, 2006 at 12:35:30AM +0200, Martin Jespersen wrote: > I just ran the following sql (on mysql 4.1.20): > > update tbl set col1=col2, col2=col1 I went through this recently with the MySQL folks and the long and short of it is that the above statement is undefined in MySQL. It may s

Re: swapping column values in update

2006-08-01 Thread Martin Jespersen
it's a frequent operation based on a where clause Barry Newton wrote: At 06:35 PM 8/1/2006, Martin Jespersen wrote: I just ran the following sql (on mysql 4.1.20): update tbl set col1=col2, col2=col1 To my surprise, mysql updates col1 via col1=col2 before reading it for use in col2=col1, s

Re: swapping column values in update

2006-08-01 Thread Barry Newton
At 06:35 PM 8/1/2006, Martin Jespersen wrote: I just ran the following sql (on mysql 4.1.20): update tbl set col1=col2, col2=col1 To my surprise, mysql updates col1 via col1=col2 before reading it for use in col2=col1, so I end up with the same value in both columns, which, of course, was n

swapping column values in update

2006-08-01 Thread Martin Jespersen
I just ran the following sql (on mysql 4.1.20): update tbl set col1=col2, col2=col1 To my surprise, mysql updates col1 via col1=col2 before reading it for use in col2=col1, so I end up with the same value in both columns, which, of course, was not my intention. Thinking about it, this behavi