0

For example table-A (id,number) table-B(id,number)

now I want to delete Table-B records if id,number combination does not exist in table-A. Can you any one help me on this? sample data:

table-A

11,1001

12,1231

13,3451

table-B

11,3451

12,1231

54,1001

so i need to delete 11,3451; 54,1001 records from table-B

Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
  • 1
    Show us db schema, sample data, current and expected output. Please read [**How-to-Ask**](http://stackoverflow.com/help/how-to-ask) And here is a great place to [**START**](http://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/) to learn how improve your question quality and get better answers. [**How to create a Minimal, Complete, and Verifiable example**](http://stackoverflow.com/help/mcve) – Juan Carlos Oropeza Aug 25 '17 at 18:39

1 Answers1

0

What about something like this to get the IDs that need to be deleted:

SELECT ID
FROM Table-B b
LEFT JOIN Table-A a on b.id = a.id AND b.number = a.number
WHERE a.id IS NULL
Cameron
  • 694
  • 4
  • 16