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!

How to replace a NOT IN Query to a join?

Vineet AroraJun 22 2011 — edited Jun 22 2011
Hi,

I have heard join queries are faster than NOT IN. Could anyone please help in converting the below query to a join query? Since, there is only one table, am not sure, if self- reference needs to be made.

Select id, name from department

where id NOT IN

*(Select id from department group by id having count(id)>1)*

order by id;Any help in this regard will be highly appreciated.
Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 20 2011
Added on Jun 22 2011
5 comments
2,823 views