Deleting a row in a single sql self join query
577162Dec 8 2008 — edited Dec 9 2008Hi
I have a table with no primary key like this...
select * from tab1;
col1 col2 col3
----------------------
1 a var1
2 b var2
3 a var1
1 a var2
2 a var1
here col3 have only two different values but col1,col2 may have different values. i did a self join like this...
select
a.*
from
tab1 a,tab1 b
where
a.col1=b.col1
and a.col2=b.col2
and a.col3<>b.col3
Now this query will give rows like this...
1 a var1
1 a var2
now i want to delete second row from same sql query...
select *from
(
select
a.col1,a.col2,a.col3
from
tab1 a,tab1 b
where
a.col1=b.col1
and a.col2=b.col2
and a.col3<>b.col3
)
where
col2=var2;
How will be it possible?
Thanks in advance....