View previous topic :: View next topic
|
Author |
Message |
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
Hi All ,
My requirement is like this
Name salary paid
bbbb 10000 y
cccc 12000 y
dddd 13000 n
eeee 14000 y
ffffff 15000 n
This is a db2 table , here i want to change the paid flag from y to n and n to y in a single DB2 Query
thanks in advance
Balaji |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
And what is the primery key for the table ?
Regards,
Priyesh. |
|
Back to top |
|
|
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
there a employee id column is foreign key in this table |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Hi balaji,
V can use a temperory flag in order to change y--n and n--y. but it will take three queries. as like swapping v can do ie., y--a and n--y finally a--n. like that. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
Back to top |
|
|
nrsmca
New User
Joined: 25 May 2005 Posts: 14
|
|
|
|
Update empsaltable a
set a.flag =
(Select (case
when (b.flag = 'y') then (n)
else (y)
end) b.flag
from empsaltable b where a.name = b.name);
Please Correct me...! |
|
Back to top |
|
|
umed
New User
Joined: 13 May 2005 Posts: 38
|
|
|
|
Hi,
u can use following query
update t1_emp a
set sex=(select distinct(sex) from t1_emp b where b.sex <> a.sex)
Let me know if u have any concerns
Regards,
Umed |
|
Back to top |
|
|
ragshere
New User
Joined: 20 Dec 2004 Posts: 70
|
|
|
|
update EMP
set paid =
( case select
when paid='Y' then 'N'
when paid='N' then 'Y'
end
)
Bye
Rags |
|
Back to top |
|
|
|