Knowledge Guide
HomeDatabasesSQL Fundamentals

FULL OUTER JOIN

A FULL OUTER JOIN in SQL is a type of join that combines rows from two or more tables based on a specified condition, and includes all rows from both the left (or first) and right (or second) tables. If there is no match, NULL values are filled in for columns from the table where no match is found.

My SQL Doesn't support Full Outer Join directly. So, we need to perform the left join and right join on two tables and then union their result.

Syntax

Follow the syntax below to perform the full outer join using the left join, right join and union.

SELECT * FROM table1 t1 LEFT JOIN table2 t2 ON t1.column_name = t2.column_name UNION SELECT * FROM table1 t1 RIGHT JOIN table2 t2 ON t1.column_name = t2.column_name;

Example

Consider two tables, students and grades:

Image
Image

Now, let's perform a FULL OUTER JOIN to retrieve information about all students and their grades:

java
SELECT s.student_id, s.student_name, g.grade
FROM Students s
LEFT JOIN Grades g ON s.student_id = g.student_id

UNION

SELECT g.student_id, s.student_name, g.grade
FROM Students s
RIGHT JOIN Grades g ON s.student_id = g.student_id;

Result

Image
Image

In this example, the FULL OUTER JOIN ensures that all students from the students table and all grades from the grades table are included in the result set. The rows that have no corresponding match in the other table display NULL values for columns from that table.

🤖 Don't fully get this? Learn it with Claude

Stuck on FULL OUTER JOIN? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **FULL OUTER JOIN** (Databases) and want to truly understand it. Explain FULL OUTER JOIN from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **FULL OUTER JOIN** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **FULL OUTER JOIN** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **FULL OUTER JOIN** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes