Data Analytics

SQL - Joins

INNER JOIN, LEFT JOIN, RIGHT JOIN, FULL OUTER JOIN, CROSS JOIN, self joins, multiple joins

20 interview questionsยท
Junior
1

Which type of join returns only rows that have a match in both tables?

Answer

INNER JOIN returns exclusively the rows where the join condition is satisfied in both tables. Rows without a match in either table are excluded from the result. It is the most commonly used join type in SQL because it guarantees that every row in the result contains complete data from both tables.

2

Which keyword is used to specify the matching condition between two tables in a join?

Answer

The ON keyword defines the matching condition between columns of both tables during a join. The standard syntax is SELECT ... FROM table1 JOIN table2 ON table1.column = table2.column. It is also possible to use USING when the join columns have the same name in both tables, but ON remains the most flexible and universal form.

3

What does a LEFT JOIN return when a row from the left table has no match in the right table?

Answer

A LEFT JOIN keeps all rows from the left table, whether or not they have a match in the right table. When there is no match, the columns from the right table are filled with NULL values. This behavior is particularly useful for identifying orphan records or ensuring that no data from the main table is lost during the join.

4

What is the main difference between LEFT JOIN and RIGHT JOIN?

5

What result does a CROSS JOIN produce?

+17 interview questions

Master Data Analytics for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free