Junior — Middle
Kuidas erineb INNER JOIN ja OUTER JOIN kasutamine SQL-is tabelite ühendamisel?
sobes.tech AI
Vastus AI-lt
Inner Join returns only those rows that have matches in both tables according to the join condition. If there is no corresponding record in one of the tables, that row will not be included in the result.
Outer Join (Left, Right, or Full) returns all rows from one or both tables, including those without matches. In such cases, missing values are filled with NULL.
Example:
-- Inner Join: only matching records
SELECT * FROM users INNER JOIN orders ON users.id = orders.user_id;
-- Left Outer Join: all users, even if they have no orders
SELECT * FROM users LEFT JOIN orders ON users.id = orders.user_id;