-1

I have Question that I have to tables Table A and Table B Overlapping each other like in vienn Diagram I want the date present only in Table A. Below I attached a picture let see that so I can explain it better. Vienn Diagram Basically I want is that the sql query should only return pink part of the diagram and all other part is neglected so I want to ask you guys that what query should I write to get that pink part only. Hope you guys Understand my question. If not feel free to ask for more explaination. And Thank you to all of those who took some time to help us guys.

Shadow
  • 33,525
  • 10
  • 51
  • 64
  • How data ovwrlap in real world example, can you demonstrate it because if you think it physically you have two table which have there own data and you can jist get it by select query – Munawar Hussian Jun 01 '21 at 14:15
  • @MunawarHussian Basically table A has a attribute ID and that ID is also there in table B (The ID in table B is a foreign key refering ID in table A) now I want a query that only return me those ID which are not in table B and only in table A (I want to skip all those ID's from table A which are also present in Table B). Hope you got my point. – Safin Mahesania Jun 01 '21 at 14:30

1 Answers1

-1

Select * from table1 where not exists (select id from table2 where table1.id = table2.id)

Try it will work for you

Munawar Hussian
  • 287
  • 1
  • 4
  • 12
  • This query will return only those rows which exist in table1 but not in table2 – Munawar Hussian Jun 01 '21 at 14:38
  • Although the above query works, it is not particularly efficient and should not really be used. The most efficient is the not exists operator as it does not have to pull data from the other table. – Shadow Jun 01 '21 at 22:52