Subject | Re: [ib-support] Oooops i mean Exchange values between Fields in one Update |
---|---|
Author | Milan Babuskov |
Post date | 2003-05-26T14:47:22Z |
Alan McDonald wrote:
SQL> create table test (a int, b int);
SQL> insert into test values (1,2);
SQL> select * from test;
A B
============ ============
1 2
SQL> update test set a = a + b, b = a - b, a = a -b;
SQL> select * from test;
A B
============ ============
2 1
By preserving b's value in a, you can retrieve it later.
--
Milan Babuskov
http://fbexport.sourceforge.net
> maybeNope. But the old +/- trick does:
> update table set field1=field2, field2=field1
> works?
SQL> create table test (a int, b int);
SQL> insert into test values (1,2);
SQL> select * from test;
A B
============ ============
1 2
SQL> update test set a = a + b, b = a - b, a = a -b;
SQL> select * from test;
A B
============ ============
2 1
By preserving b's value in a, you can retrieve it later.
--
Milan Babuskov
http://fbexport.sourceforge.net