SQL Joins questions and answers
Inner, left, right, full, cross and self joins, and row counts. Practise sql joins questions from the sql section of placement tests, with a worked explanation after every answer. Practice is free and needs no sign-up.
Sample sql joins questions with worked answers
Question 1
In A LEFT JOIN B, what happens to a row of A that has no matching row in B?
- It is dropped from the result
- It is paired with every row of B
- It appears once, with B's columns copied from the previous matched row
- It appears once, with NULL in every column that comes from B
Answer: D. It appears once, with NULL in every column that comes from B
Explanation: A left join keeps every row of the left table. When there is no match, the right table's columns are filled with NULL so the left row is not lost.
Question 2
Tables Authors(author_id, name) and Books(book_id, title, author_id) exist. Which query lists every author with their book titles, including authors who have not written any book?
- SELECT a.name, b.title FROM Authors a INNER JOIN Books b ON a.author_id = b.author_id;
- SELECT a.name, b.title FROM Authors a LEFT JOIN Books b ON a.author_id = b.author_id;
- SELECT a.name, b.title FROM Books b LEFT JOIN Authors a ON a.author_id = b.author_id;
- SELECT a.name, b.title FROM Authors a RIGHT JOIN Books b ON a.author_id = b.author_id;
Answer: B. SELECT a.name, b.title FROM Authors a LEFT JOIN Books b ON a.author_id = b.author_id;
Explanation: The table whose rows must all be kept, Authors, has to be on the preserved side. Authors LEFT JOIN Books does that; the inner join drops authors without books, and the other two preserve Books instead.
Question 3
Table A has m rows. Table B has n rows and B.k is its primary key. How many rows does A LEFT JOIN B ON A.k = B.k return?
- Exactly n
- m + n
- Anything from m to m × n, depending on the data
- Exactly m
Answer: D. Exactly m
Explanation: Because B.k is unique, a row of A can match at most one row of B, so no A row is duplicated. The left join also keeps the A rows that match nothing, so the result has exactly m rows.
All 20 sql joins questions with answers
- 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 Colours: colour Red Blue Green Table Sizes: size S M How many rows does…
- In A LEFT JOIN B, what happens to a row of A that has no matching row in B?
- 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 |…
- Which of these is equivalent to A RIGHT JOIN B ON A.k = B.k (ignoring column…
- 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 Learners: name | city Isha | Delhi Jatin | Delhi Kiran | Pune Leela |…
- 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…
- Table Staff: emp_id | name | manager_id 1 | Nandini | NULL 2 | Omkar | 1 3 |…
- Table A has m rows. Table B has n rows and B.k is its primary key. How many…
SQL Joins: common questions
What are sql joins questions?
Inner, left, right, full, cross and self joins, and row counts. They appear in the sql section of many placement tests.
Where can I practise sql joins questions with answers for free?
Right here on LogicWiz Exams. Every sql joins question has a worked explanation after you answer. Practice is free and needs no sign-up.
How should I practise sql joins?
Start with easy questions, then move to medium and hard. Read the explanation after each answer, and come back to the ones you missed.
Start practising
On this page you can start a fresh set of sql joins questions, choose easy, medium or hard, and time yourself if you want to. Or practise the whole subject: SQL practice.
More sql topics
- SELECT, WHERE & ORDER BY: Filtering, DISTINCT, IN, BETWEEN, LIKE, sorting and LIMIT.
- Aggregates & GROUP BY: COUNT, SUM, AVG, grouping and HAVING versus WHERE.
- Subqueries & CTEs: Scalar and correlated subqueries, IN, EXISTS and WITH.
- Window Functions: ROW_NUMBER, RANK, DENSE_RANK, PARTITION BY, LAG and running totals.
- NULL Handling: Three-valued logic, IS NULL, COALESCE and NULL in aggregates.
- SQL Functions & CASE: CASE WHEN, conditional aggregation, string and numeric functions.
- UNION, INTERSECT & EXCEPT: Combining results, duplicates and column rules.
- Tables, Keys & Constraints: CREATE, ALTER, primary and foreign keys, UNIQUE and CHECK.
- DML & Transactions: INSERT, UPDATE, DELETE, COMMIT, ROLLBACK and ACID.
Other subjects
- Quantitative Aptitude: Arithmetic, percentages, time and work, speed, probability and data interpretation: the numerical section of every fresher test.
- Logical Reasoning: Series, coding-decoding, arrangements, syllogisms and puzzles: the section that separates prepared candidates from the rest.
- Verbal Ability: Vocabulary, grammar, reading comprehension and sentence order: tested in nearly every IT services hiring exam.
- Technical & Programming: CS fundamentals, output prediction and pseudo-code: the technical MCQ round for IT roles.
- Python: Python quizzes by topic, from types and strings to classes and generators: output prediction and interview concepts.
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge · Test from a job description · LogicWiz Open: free team quiz · Free interview prep