From the course: From Excel to SQL

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using VLOOKUP, HLOOKUP, XLOOKUP in SQL

Using VLOOKUP, HLOOKUP, XLOOKUP in SQL

From the course: From Excel to SQL

Start my 1-month free trial

Using VLOOKUP, HLOOKUP, XLOOKUP in SQL

- If you want to combine data from different tables and worksheets in Excel, chances are you've reached for one of the various lookup functions that Excel provides. So we're talking about VLOOKUP, HLOOKUP, or the newer XLOOKUP. If you take a look at the sample Excel spreadsheet on the sheet called Lookup State, you can see a simple example of this. Here the State column has been filled using a VLOOKUP on the department data. And you might have done something similar to this before. Now, the bad news is there is no function called VLOOKUP, HLOOKUP, or XLOOKUP in SQL. The good news is they can still combine data from multiple tables by using the JOIN clause. So let's take a look at how the same VLOOKUP in Excel can be easily performed in SQL. Let's open up DB Browser and click on the Execute SQL tab. If you want to list all the employees with their state information, you would use a JOIN, like this. Firstly, let's select…

Contents