What is INNER JOIN in SQL? - Demystifying SQL JOINS

Inner joins are used for combining data from tables where there is a match in given condition on both tables - usually primary key from one table and foreign key from another are used for matching. 

Customers

customer_id name country
1 Alice USA
2 Bob UK
3 Charlie Germany

Orders

order_id customer_id order_amount
101 1 250
102 1 125
103 2 300
104 4 400

 

INNER JOIN QUERY

SELECT Customers.name, Orders.order_amount
FROM Customers
INNER JOIN Orders
ON Customers.customer_id = Orders.customer_id;

 Result:

name order_amount
Alice 250
Alice 125
Bob 300

Note: Charlie and order_id 104 are not shown because there's no matching customer_id