How to join two CSV files with SQL
A VLOOKUP works until you need a one-to-many match, a multi-column join, or an aggregate on top of it — then it turns into a mess of helper columns. Load both files into Synth as separate tables instead, and join them with one real SQL query.
Upload both files
Upload your first CSV to start a workspace, then use + Add table to load the second one alongside it. Each file becomes its own table, queryable on its own or together.
Write the join
Say you have an orders.csv and a customers.csv, related by a customer ID column in both:
SELECT customers.name, orders.total, orders.status
FROM orders
JOIN customers ON orders.customer_id = customers.id;
That's a standard inner join — only rows with a match in both tables. Need every order even without a matching customer row, or vice versa?
SELECT customers.name, orders.total
FROM orders
LEFT JOIN customers ON orders.customer_id = customers.id;
Let Synth suggest the join for you
Once you have two or more tables loaded, open the Relationships tab. Synth compares column names and values across your tables and suggests likely relationships automatically, shown as dashed lines between matching columns. Confirm the real ones — shown solid once confirmed — and the AI assistant uses them as join hints the next time you ask it a cross-table question, so it writes the JOIN correctly without you specifying it every time.
Aggregate across the join
The real advantage over a spreadsheet lookup shows up once you need to aggregate after joining — a total per customer across every one of their orders, for example:
SELECT customers.name, COUNT(orders.id) AS order_count, SUM(orders.total) AS lifetime_value
FROM orders
JOIN customers ON orders.customer_id = customers.id
GROUP BY customers.name
ORDER BY lifetime_value DESC;
See the SQL cheat sheet for more join and aggregation patterns.
Frequently asked questions
How do I join two CSV files?
Upload both CSV files into the same Synth workspace as separate tables, then write a standard SQL JOIN across them on a shared column — the same way you'd join two tables in any relational database.
Can Synth detect which columns to join on automatically?
Yes. Synth's relationship detection suggests likely foreign-key relationships between tables by matching column names and values, shown as dashed lines you can confirm or reject before the AI assistant uses them as join hints.
Is this better than VLOOKUP in Excel or Google Sheets?
For anything beyond a simple one-to-one lookup, yes — a real SQL JOIN handles one-to-many and many-to-many relationships, multiple join conditions, and aggregation after the join natively, where VLOOKUP or INDEX/MATCH need increasingly awkward workarounds.
How many CSV files can I join at once?
Synth's Premium tier supports up to 10 tables in one workspace, joinable in any combination a single SQL query supports.