Sobes.tech
Junior — Middle

Что произойдет в итоговой таблице после выполнения LEFT JOIN, если в правой таблице отсутствуют соответствующие записи?

sobes.tech AI

Answer from AI

When performing a LEFT JOIN, the resulting table contains all records from the left (first) table. If there are no matching records in the right (second) table for a record from the left table, the columns from the right table will have NULL values in the result.

Example:

If there is a table A:

id name
1 Alice
2 Bob

and a table B:

id city
1 London

Query:

SELECT A.id, A.name, B.city
FROM A
LEFT JOIN B ON A.id = B.id;

Result:

id name city
1 Alice London
2 Bob NULL

Thus, records from the left table are always present, and missing matches on the right are filled with NULL.