|
Posted by Captain Paralytic on 02/21/07 10:04
On 21 Feb, 04:10, Norman Peelman <npeel...@cfl.rr.com> wrote:
> David Smithz wrote:
> > "Paul Lautman" <paul.laut...@btinternet.com> wrote in message
> >news:5416e9F1ug8raU1@mid.individual.net...
> > In fact I have now managed to try it on an isolated row that I fixed
> > afterwards and unfortunately it works how I don't want it to. Therefore both
> > the fields become the same value.
>
> > So how can I achieve this?
>
> David,
>
> Use either multiple queries or user-defined variables. Try this
> (given a table with fields `A` and `B`:
>
> UPDATE tablename SET A = B, B := @tmp WHERE @tmp := A
>
> Nice one liner SQL that swaps two fields. :)
>
> Norm
> ...the WHERE clause gets evaluated first.
I tried
UPDATE `cars`
SET `car` = `state`,
`state` = @A
WHERE @A := `car`
and no rows were affected.
Navigation:
[Reply to this message]
|