How to join two Excel sheets with SQL
Connect orders to customer names using a shared customer_id. This example works with two worksheets in one workbook or two separate CSV files.
1. Open the sample workbook
Download the Excel workbook, then open it with Import Wizard. Name the tables orders and customers. Alternatively, download orders.csv and customers.csv.
The workbook contains these two sheets:
| order_id | customer_id | amount |
|---|---|---|
| 101 | 1 | 100 |
| 102 | 2 | 50 |
| 103 | 1 | 25 |
| customer_id | customer_name |
|---|---|
| 1 | Ada |
| 2 | Linus |
2. Join on the shared key
SELECT o.order_id, c.customer_name, o.amount
FROM orders AS o
JOIN customers AS c ON o.customer_id = c.customer_id
ORDER BY o.order_id;The aliases o and c identify each table. INNER JOIN includes only rows whose customer IDs match. If imported table names differ, replace them with the exact names in Database Structure.
3. Check the expected result
| order_id | customer_name | amount |
|---|---|---|
| 101 | Ada | 100 |
| 102 | Linus | 50 |
| 103 | Ada | 25 |
4. Find orders without a matching customer
SELECT o.order_id, o.customer_id
FROM orders AS o
LEFT JOIN customers AS c ON o.customer_id = c.customer_id
WHERE c.customer_id IS NULL;The sample returns no unmatched orders. In your own data, this is a useful check for missing customer records. Duplicate customer IDs in the Customers table can multiply result rows; check key uniqueness before trusting totals.
5. Export and keep your work
Download the result as CSV. Both tables are saved locally and restored when you return to the app. Download the SQLite database as a portable backup.