How to Do a VLOOKUP in SQL (LEFT JOIN Explained for Excel Users)
Already know VLOOKUP or XLOOKUP? Then you already understand SQL LEFT JOIN — learn the exact 1-to-1 translation with live practice.
VLOOKUP and LEFT JOIN solve the exact same problem
In Excel, VLOOKUP takes every row in your main sheet and pulls matching columns from a lookup table — leaving #N/A when no match exists. In SQL, LEFT JOIN keeps every row from your left table and pulls matching columns from the right table — leaving NULL when no match exists.
The 1-to-1 syntax mapping
Your Excel lookup_value becomes the ON key (ON orders.customer_id = customers.customer_id). Your return column becomes a column in SELECT (SELECT orders.order_id, customers.full_name). Unlike VLOOKUP, SQL LEFT JOIN can return 10 columns at once and never breaks if columns move.
One big catch: duplicate keys
VLOOKUP silently returns only the first match when a lookup table has duplicate IDs. SQL LEFT JOIN returns one output row per matching pair — so always check row counts with COUNT(*) after joining!
Put this into practice in 4 minutes
Try real interactive Excel, Google Sheets, and SQL exercises — every core lesson is free to study.
Free 1-Page Excel, Google Sheets & SQL Interview Cheat Sheet
The 25 formulas, keyboard shortcuts, and SQL patterns tested most in analyst interviews — emailed instantly, zero spam.