db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sarah.kho" <sarah....@gmail.com>
Subject Re: how I can swap content of two fields in one table?
Date Tue, 11 Aug 2009 22:57:30 GMT

Than you Knut,
It worked charming.

Thanks.

Knut Anders Hatlen wrote:
> 
> "sarah.kho" <sarah.kho@gmail.com> writes:
> 
>> Hi
>> Is there an easy way to swap content of two fields (sn and ssn) in a
>> table
>> with hundreds of rows?
> 
> An update statement with "SET SN=SSN, SNN=SN" should do the trick. See
> the example below.
> 
> ij> select * from t;
> X   |Y   
> ---------
> x1  |y1  
> x2  |y2  
> x3  |y3  
> 
> 3 rows selected
> ij> update t set x=y, y=x;
> 3 rows inserted/updated/deleted
> ij> select * from t;
> X   |Y   
> ---------
> y1  |x1  
> y2  |x2  
> y3  |x3  
> 
> 3 rows selected
> 
> Hope this helps,
> 
> -- 
> Knut Anders
> 
> 

-- 
View this message in context: http://www.nabble.com/how-I-can-swap-content-of-two-fields-in-one-table--tp24875562p24927220.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message