An INNER JOIN is a term used in SQL (Structured Query Language) to combine rows from two (or more) tables based on a related column between them.
You have two tables:
Table: Customers
CustomerID | Name |
---|---|
1 | Anna |
2 | Bernd |
3 | Clara |
Table: Orders
OrderID | CustomerID | Product |
---|---|---|
101 | 1 | Book |
102 | 2 | Laptop |
103 | 4 | Phone |
Now you want to know which customers have placed orders. You only want the customers who exist in both tables.
SELECT Customers.Name, Orders.Product
FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
Name | Product |
---|---|
Anna | Book |
Bernd | Laptop |
Clara didn’t place any orders → not included.
The order with CustomerID 4 doesn’t match any customer → also excluded.
An INNER JOIN returns only the rows with matching values in both tables.