Introduction
A FULL OUTER JOIN helps you combine two tables and keep all rows from both, even if they don't match.
Jump into concepts and practice - no test required
SELECT columns FROM table1 FULL OUTER JOIN table2 ON table1.common_column = table2.common_column;
SELECT * FROM employees FULL OUTER JOIN departments ON employees.department_id = departments.id;
SELECT orders.id, customers.name FROM orders FULL OUTER JOIN customers ON orders.customer_id = customers.id;
CREATE TABLE students (id INT, name VARCHAR(10)); CREATE TABLE scores (student_id INT, score INT); INSERT INTO students VALUES (1, 'Amy'), (2, 'Bob'), (3, 'Cara'); INSERT INTO scores VALUES (2, 85), (3, 90), (4, 75); SELECT students.id, students.name, scores.score FROM students FULL OUTER JOIN scores ON students.id = scores.student_id ORDER BY students.id NULLS LAST, scores.student_id NULLS LAST;
FULL OUTER JOIN do in SQL?Employees and Departments on DeptID?Table A:Table B:SELECT A.ID, A.Name, B.City FROM A FULL OUTER JOIN B ON A.ID = B.ID ORDER BY A.ID;
SELECT * FROM Customers FULL OUTER JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Orders.OrderID IS NULL;
Products:Sales: