1 Replies - 5997 Views - Last Post: 05 June 2012 - 04:36 AM

#1 campbell0988  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 11
  • Joined: 12-May 12

replace a minus set operator with exist/not exist statement?

Posted 15 May 2012 - 04:30 AM

Does anyone know how I would go about using a exist/ not exist statement instead of a minus set operator?
thanks
Is This A Good Question/Topic? 0
  • +

Replies To: replace a minus set operator with exist/not exist statement?

#2 Nidhesh  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 9
  • Joined: 10-June 10

Re: replace a minus set operator with exist/not exist statement?

Posted 05 June 2012 - 04:36 AM

Let's assume you have 2 tables, A and B with common column called ID.
If I have undertood your question correctly you want to use the EXIST/NOT EXISTS to find all the records in table A which do not exists in table B.

A set difference query will be
Select A.* from A left join B on A.ID=B.ID where B.ID is null


Same query using Not Exist would be
Select A.* from A where not exists (select 1 from B where A.ID=B.ID)

Was This Post Helpful? 2
  • +
  • -

Page 1 of 1