SQLSheet

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_idcustomer_idamount
1011100
102250
103125
customer_idcustomer_name
1Ada
2Linus

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.

Open this example in SQLSheet

3. Check the expected result

order_idcustomer_nameamount
101Ada100
102Linus50
103Ada25

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.

More about querying Excel with SQL ยท Check duplicate IDs