Find Common Customers Using INTERSECT
📖 Scenario: You work for a company that has two sales databases. Each database has a table of customers who made purchases in different regions. You want to find customers who bought products in both regions.
🎯 Goal: Create two tables named region1_customers and region2_customers with customer names. Then write a query using INTERSECT to find customers common to both regions.
📋 What You'll Learn
Create a table called
region1_customers with a column customer_name and insert these exact names: 'Alice', 'Bob', 'Charlie', 'Diana'Create a table called
region2_customers with a column customer_name and insert these exact names: 'Bob', 'Diana', 'Eve', 'Frank'Write a query using
INTERSECT to select customer_name from both tables to find common customersComplete the final query to show only the common customer names
💡 Why This Matters
🌍 Real World
Companies often need to find customers or data points common to multiple datasets or regions to analyze overlapping markets or shared customers.
💼 Career
Knowing how to use INTERSECT helps database analysts and developers write efficient queries to compare datasets and find common records.
Progress0 / 4 steps