Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Deleting a row in a single sql self join query

577162Dec 8 2008 — edited Dec 9 2008
Hi

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....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 6 2009
Added on Dec 8 2008
9 comments
1,095 views