| Garlapati |
Posted: Mar 04, 2008 04:44:00 AM |
Total Post: 30
Joined: Apr, 2007
|
i have a table with two columns
1) name
2) sex
i am little bit confuse plz give me soultion
i want to update males with female
female with male
after updation
male row should be female
and female row should be male
i want to exchange the male with female
and females with males
viseversa
thanq in dvance
|
|
|
Murtuja |
| Posted: Mar 04, 2008 05:26:10 AM | |
|
Total Post: 857
Joined: Jan, 2006
|
You have to issue update statement three time to achive that.
update table_a
set sex='M_Temp'
where sex='F'
update table_a
set sex='F'
where sex='M'
update table_a
set sex='M'
where sex='M_Temp'
|
|
|
|
|
Garlapati |
| Posted: Mar 05, 2008 02:40:30 AM | |
|
Total Post: 30
Joined: Apr, 2007
|
Thanq, but is there any sql statement or pl/sql subprogramme for this
if plz forward it ..
thanq
|
|
|
|
|
sad |
| Posted: Mar 05, 2008 07:17:32 AM | |
|
Total Post: 24
Joined: Feb, 2008
|
Hi Murtuja,
update table_a
set sex='F'
where sex='M'
I think this command wont work.. bcoz we cant use the same column name in both 'set' and 'where' condition
|
|
|
|
|
jayesh |
| Posted: Mar 05, 2008 09:18:19 AM | |
|
Total Post: 60
Joined: Jan, 2008
|
UPDATE table_name
SET DECODE(GENDER,'M','F','F','M');
just try it.
|
|
|
|
|
jayesh |
| Posted: Mar 07, 2008 09:55:28 AM | |
|
Total Post: 60
Joined: Jan, 2008
|
sorry the right statement for this kinda update is
update table_name
set column_name= decode(column_name,'m','f','f','m');
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |