PostgreSQL and SQL Server support FULL OUTER JOIN directly. MySQL and SQLite do not have native FULL OUTER JOIN syntax.
Table A:
id | name
1 | Alice
2 | Bob
Table B:
id | city
2 | Paris
3 | Tokyo
What is the result of:
SELECT A.id, A.name, B.city FROM A FULL OUTER JOIN B ON A.id = B.id ORDER BY A.id, B.id;
CREATE TABLE A (id INT, name TEXT); INSERT INTO A VALUES (1, 'Alice'), (2, 'Bob'); CREATE TABLE B (id INT, city TEXT); INSERT INTO B VALUES (2, 'Paris'), (3, 'Tokyo'); SELECT A.id, A.name, B.city FROM A FULL OUTER JOIN B ON A.id = B.id ORDER BY A.id, B.id;
The FULL OUTER JOIN returns all rows from both tables. For id=1, only A has data, so city is NULL. For id=2, both tables have data. For id=3, only B has data, so name is NULL.
Option D uses LEFT JOIN and UNION to combine all rows from both tables, simulating FULL OUTER JOIN. Option D uses UNION ALL but misses filtering correctly. Option D is INNER JOIN only. Option D is invalid syntax in MySQL.
Indexes on join columns speed up matching rows in joins. Removing indexes or using CROSS JOIN will degrade performance or change results.
SELECT A.id, B.id FROM A FULL OUTER JOIN B ON A.id = B.id;
Why does it fail in SQLite?
SQLite does not support FULL OUTER JOIN syntax at all, so the query fails with a syntax error.
