0
0
SQLquery~30 mins

FULL OUTER JOIN availability across databases in SQL - Mini Project: Build & Apply

Choose your learning style9 modes available
Explore FULL OUTER JOIN Availability Across Databases
📖 Scenario: You are working with two different databases that store customer orders and customer feedback separately. You want to combine this information to see all customers who have either placed an order, given feedback, or both.
🎯 Goal: Build SQL queries to perform a FULL OUTER JOIN between two tables orders and feedback to find all customers with their order and feedback details, and understand how FULL OUTER JOIN works in different database systems.
📋 What You'll Learn
Create two tables named orders and feedback with specified columns and data.
Add a configuration variable to specify the database system (e.g., 'PostgreSQL', 'MySQL').
Write a FULL OUTER JOIN query to combine orders and feedback on customer_id.
Add a final note or query to handle databases that do not support FULL OUTER JOIN natively.
💡 Why This Matters
🌍 Real World
Combining customer orders and feedback data from different sources to get a complete view of customer interactions.
💼 Career
Understanding FULL OUTER JOIN and its availability helps database professionals write compatible queries across different database systems.
Progress0 / 4 steps
1
Create tables orders and feedback with sample data
Create a table called orders with columns customer_id (integer) and order_amount (integer). Insert these rows exactly: (1, 100), (2, 150), (4, 200). Then create a table called feedback with columns customer_id (integer) and comments (text). Insert these rows exactly: (2, 'Good service'), (3, 'Late delivery'), (4, 'Excellent').
SQL
Need a hint?

Use CREATE TABLE statements for both tables and INSERT INTO to add the exact rows.

2
Set the database system variable
Create a variable called db_system and set it to the string 'PostgreSQL' to represent the database you are using.
SQL
Need a hint?

Assign the string 'PostgreSQL' to the variable db_system.

3
Write a FULL OUTER JOIN query to combine orders and feedback
Write a SQL query called full_outer_join_query that selects orders.customer_id, order_amount, and comments from orders FULL OUTER JOIN feedback on orders.customer_id = feedback.customer_id.
SQL
Need a hint?

Use FULL OUTER JOIN to combine the tables on customer_id.

4
Add a query for databases without FULL OUTER JOIN support
Write a SQL query called alternative_query that uses UNION of LEFT JOIN and RIGHT JOIN to simulate a FULL OUTER JOIN between orders and feedback on customer_id.
SQL
Need a hint?

Use LEFT JOIN and RIGHT JOIN combined with UNION to mimic FULL OUTER JOIN.