SQL Language (MOSC)

MOSC Banner

delete duplicate rows from joining tables

edited Feb 18, 2010 5:11AM in SQL Language (MOSC) 6 commentsAnswered
 Hi,

Table names A and B

Duplicated result set from A and B

select a.*,b.* from a,b

where a. id in (select b.id from b where id=8888 group by id having count(id) > 1)

 

The result as follows

 

a.id,        a.name,          b.id ,              b.name

001            Adam            002                  Adam

002            Adam            002                 Adam

003             frank           003                  frank

004               frank           004                  frank

 I want to delete rows from table 'a' using the above result set/SQL ( there are about million duplicates)

something as follows

delete from  a

where rowid > (select min(a.rowid)

where a. id in (select b.id from b where id=8888 group by id having count(id) > 1))

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center