VIPSolutions logo ✨ VIPSolutions

Q7. Given two table find out the records which are not common in both? [[»] ID ID [>] [>] 10 10 20 10 10 20 30 40 20 null 30 50 30 30 40 40 Null 50 50 50 select a.id from table1 a left join table2 b on a.id=b.id where b.id is null & Ne OF 4

Question:

Uploaded ImageQ7. Given two table find out the records which are not common in both? [[»] ID ID [>] [>] 10 10 20 10 10 20 30 40 20 null 30 50 30 30 40 40 Null 50 50 50 select a.id from table1 a left join table2 b on a.id=b.id where b.id is null & Ne OF 4

This is AI generated Response.
Asked by: Farhan Akhtar
Created at: 2025-08-08 20:32:42

Final Answer:

Rendered Raw Text
Did you like this answer?
This image presents a SQL interview question: **Question**: "Given two tables, find out the records which are not common in both?" **Tables:** | Table1 | Table2 | |--------|--------| | 10 | 10 | | 20 | 30 | | 30 | 50 | | 40 | | | 50 | | **Output required:** ``` ID 20 40 ``` (IDs present in Table1 but *not* in Table2.) **Approach:** The solution uses a **LEFT JOIN** to find records in Table1 that do not exist in Table2: ```sql SELECT a.id FROM table1 a LEFT JOIN table2 b ON a.id = b.id WHERE b.id IS NULL; ``` **Explanation:** - The `LEFT JOIN` returns all rows from Table1 and the matched rows from Table2. - If there is no match, the result is NULL from Table2. - `WHERE b.id IS NULL` filters out only those rows where there was no match, i.e., the IDs not present in Table2. **Diagram on the right:** It visually shows how the join works, producing NULLs where there is no match, which are then filtered in the output. **Summary:** This SQL technique helps in finding records present in one table but not the other, commonly referred to as "anti-join".

📢 Instructions:

  • Ask anything relatd to above question only.
  • For new Question goto :

Study Help, Fast Answers

VIPSolutions focuses on clear, step‑by‑step explanations so you can learn quickly. Whether you need an AI‑generated walkthrough or a short hint to get unstuck, each solution is organized for fast reading and easy review later.

Search similar questions, compare approaches, and bookmark the best answers for revision. Our goal is simple: quick, reliable study help that feels natural—not noisy.