Understanding FULL OUTER JOIN Behavior in SQL
📖 Scenario: You work in a small bookstore. You have two lists: one with books currently in stock and another with books ordered but not yet arrived. You want to see all books, whether they are in stock, ordered, or both.
🎯 Goal: Create two tables in_stock and ordered with book titles and quantities. Then write a FULL OUTER JOIN query to combine these tables, showing all books with their stock and order quantities.
📋 What You'll Learn
Create a table called
in_stock with columns book_title (text) and quantity_in_stock (integer).Insert exactly these rows into
in_stock: ('The Hobbit', 5), ('1984', 8), ('Dune', 3).Create a table called
ordered with columns book_title (text) and quantity_ordered (integer).Insert exactly these rows into
ordered: ('Dune', 7), ('The Catcher in the Rye', 4), ('1984', 2).Write a
FULL OUTER JOIN query joining in_stock and ordered on book_title.Select
book_title, quantity_in_stock, and quantity_ordered in the result.💡 Why This Matters
🌍 Real World
Bookstores and inventory systems often need to combine data from current stock and incoming orders to manage inventory effectively.
💼 Career
Understanding FULL OUTER JOIN is important for database analysts and developers who work with relational databases to combine and analyze data from multiple sources.
Progress0 / 4 steps