Find records from one table which doesn’t exist in another in SQL.

Here I make a two tables.it’s following.

Information:

ID NAME ADDRESS
1 aaa Palanpur
2 bbb Deesa

Information_book

ID NAME ADDRESS
1 aaa Palanpur
2 bbb Deesa
3 ccc Ahmedabad
Now,you want to find out the record in information_book table
but this record doesn’t exist in the information table.

This time you fire following query…

This query is easily find the record and easy to understand.

Query:-
SELECT * FROM information_book WHERE
address NOT IN (SELECT address FROM information_book);

You want to find alternet record So,fire this query.

Query:-
SELECT * FROM information_book WHERE NOT EXISTS

(SELECT * FROM information WHERE information.address = information.address)

Your output is bellow.

Information_book

ID NAME ADDRESS
3 ccc Ahmedabad

About the Author

avatar