SQL Joins · Question 8 · Medium

SQL Joins question 8

Table Teams:
team_id | team | city
1 | CSK | Chennai
2 | MI | Mumbai
3 | RCB | Bengaluru
4 | GT | Ahmedabad

Table Players:
player_id | name | team_id
1 | Ajay | 1
2 | Bala | 1
3 | Chetan | 2
4 | Dinesh | 3
5 | Eshan | NULL
6 | Farid | 7

What does this query return?

SELECT t.team
FROM Teams t
LEFT JOIN Players p ON t.team_id = p.team_id
WHERE p.player_id IS NULL;
  1. CSK; MI; RCB
  2. No rows
  3. NULL
  4. GT
Answer and explanation

Answer: D. GT

Explanation: The left join keeps GT with NULLs in the Players columns because no player has team_id 4. Filtering on p.player_id IS NULL keeps exactly such unmatched left rows; this is the anti-join pattern.

Previous: Which of these is equivalent to A RIGHT JOIN B ON A.k = B.k (ignoring column… · Next: Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |…

Practise sql joins

Try a fresh set of sql joins questions with an explanation after every answer, free and without signing up: SQL Joins practice. Or sit a full placement mock test.

More sql joins questions

More sql practice

Aggregates & GROUP BY · Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge