Union, Intersection, and Difference in SQL
📖 Scenario: You work in a company database where you have two tables: Employees_USA and Employees_Canada. Each table lists employees working in that country.You want to learn how to combine and compare these tables using SQL operations: union, intersection, and difference.
🎯 Goal: Build SQL queries to find:All employees working in either USA or Canada (union)Employees working in both USA and Canada (intersection)Employees working in USA but not in Canada (difference)
📋 What You'll Learn
Create two tables
Employees_USA and Employees_Canada with exact employee namesWrite a SQL query using
UNION to combine all employees from both tablesWrite a SQL query using
INTERSECT to find employees common to both tablesWrite a SQL query using
EXCEPT to find employees in USA but not in Canada💡 Why This Matters
🌍 Real World
Combining and comparing data from different sources or departments is common in business databases.
💼 Career
Knowing how to use UNION, INTERSECT, and EXCEPT helps database analysts and developers write efficient queries for data analysis and reporting.
Progress0 / 4 steps