Home » SQL & PL/SQL » SQL & PL/SQL » Swapping in Sql
Swapping in Sql [message #11074] Thu, 04 March 2004 15:21 Go to next message
k. sasikumar
Messages: 6
Registered: September 2003
Junior Member
How to swap two columns in Sql (for Updating the
data on the same table)?
Re: Swapping in Sql [message #11075 is a reply to message #11074] Thu, 04 March 2004 15:25 Go to previous message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
Pretty straightforward:

SQL> select * from t;
 
        C1         C2
---------- ----------
         1          2
         3          4
 
SQL> update t set c1=c2, c2=c1;
 
2 rows updated.
 
SQL> select * from t;
 
        C1         C2
---------- ----------
         2          1
         4          3
Previous Topic: Urgent
Next Topic: HOW CAN I PUT CONSTRAINTS IN A TABLE THAT HAVE EXITS IN A DATABASE
Goto Forum:
  


Current Time: Fri Apr 19 17:19:56 CDT 2024