SQL Joins · Question 11 · Medium
SQL Joins question 11
Table Learners:
name | city
Isha | Delhi
Jatin | Delhi
Kiran | Pune
Leela | Goa
Table Centres:
centre | city
C1 | Delhi
C2 | Delhi
C3 | Pune
C4 | Surat
city is not a key in either table. How many rows does this query return?
SELECT l.name, c.centre
FROM Learners l
JOIN Centres c ON l.city = c.city;
- 3 rows
- 4 rows
- 5 rows
- 8 rows
Answer and explanation
Answer: C. 5 rows
Explanation: Each Delhi learner matches both Delhi centres, giving 2 × 2 = 4 rows, and Kiran matches C3 once. Leela (Goa) and C4 (Surat) match nothing, so the total is 5.
Previous: Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |… · Next: Table Staff: emp_id | name | manager_id 1 | Nandini | NULL 2 | Omkar | 1 3 |…
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
- Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |…
- Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |…
- Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |…
- Table Staff: emp_id | name | manager_id 1 | Nandini | NULL 2 | Omkar | 1 3 |…
- Table Riders: rider_id | name 1 | Manoj 2 | Nisha 3 | Om Table Trips: trip_id…
- Table Riders: rider_id | name 1 | Manoj 2 | Nisha 3 | Om Table Trips: trip_id…
- Tables Authors(author_id, name) and Books(book_id, title, author_id) exist…
- Table Teams: team_id | team | city 1 | CSK | Chennai 2 | MI | Mumbai 3 | RCB |…
- Table Riders: rider_id | name 1 | Manoj 2 | Nisha 3 | Om Table Trips: trip_id…
- Table Invoices: inv_id | customer | total 1 | Zoya | 1000 2 | Arun | 500 Table…
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