Google Sheets Query Join Two Tables: How To

How-to basics · Updated November 23, 2026

To join two tables in Google Sheets, use the QUERY function with ARRAYFORMULA and IFERROR to simulate a LEFT JOIN, or use FILTER with MATCH for a simple lookup-based merge. There is no native JOIN clause in Google Sheets’ QUERY, but you can combine tables by matching keys with array formulas or use the built-in VLOOKUP for one-to-one joins.

Why Google Sheets Has No Direct JOIN

Unlike SQL databases, Google Sheets’ QUERY function (which uses a Google Visualization API query language) does not support a JOIN keyword. This is a common frustration for users coming from Excel or SQL. The workaround is to use array formulas that pair rows based on a common column, effectively performing a join manually. For most practical purposes, you can achieve the same result as an SQL join by combining QUERY with ARRAYFORMULA and IFERROR.

The Core Technique: Simulating a LEFT JOIN

Assume you have two sheets: Orders (columns: OrderID, CustomerID, Amount) and Customers (columns: CustomerID, Name, City). You want a list of all orders with the customer name.

In a new sheet, put this formula in cell A1:

=QUERY({Orders!A:C, IFERROR(ARRAYFORMULA(VLOOKUP(Orders!B:B, Customers!A:C, 2, FALSE)), "Unknown")}, "select * where Col1 is not null", 1)

Here’s what happens: VLOOKUP looks up each CustomerID from Orders in the Customers table and returns the Name (column 2). ARRAYFORMULA makes it work for the whole column. IFERROR replaces missing matches with “Unknown”. The {...} creates an array with the original order columns plus the looked-up name. Then QUERY selects all rows, skipping blanks. The result is a table with OrderID, CustomerID, Amount, and Name.

This is a LEFT JOIN because all rows from Orders appear, even if no customer matches.

Using VLOOKUP for a Simple One-Column Join

If you only need to pull one column from the second table, VLOOKUP alone is simpler. With the same example, put this in cell D2 (assuming Orders data is in A2:C10):

=ARRAYFORMULA(IFERROR(VLOOKUP(B2:B10, Customers!A:C, 2, FALSE), "Not found"))

This fills D2:D10 with the customer name for each order. It’s a LEFT JOIN equivalent. For a RIGHT JOIN (keep all customers), you’d start with the Customers table and look up orders, which is less common.

When to Use FILTER and MATCH Instead

If you need a full outer join (all rows from both tables), use FILTER with MATCH to identify rows that exist in both. For example, to get orders that have a matching customer:

=FILTER(Orders!A:C, COUNTIF(Customers!A:A, Orders!B:B)>0)

This returns only orders where the CustomerID exists in the Customers table. To get orders without a match, invert the condition. Combining these with curly braces can give you a full outer join, but it’s more complex. For most users, the VLOOKUP approach is sufficient.

How to Choose the Right Method

  • One column from second table: Use VLOOKUP with ARRAYFORMULA.
  • Multiple columns from second table: Use the QUERY with array and VLOOKUP for each column, or use INDEX with MATCH.
  • Need to filter or aggregate after join: Use QUERY with the array approach, because you can add where, group by, etc.
  • Large data sets (over 50,000 rows): Consider using QUERY with IMPORTRANGE if the tables are in different files, but be aware of performance limits.

Common Problems and Solutions

  • #N/A errors: Wrap VLOOKUP in IFERROR to return a default value.
  • Mismatched data types: If keys are numbers in one table and text in another, use TEXT function to normalize, e.g., VLOOKUP(TEXT(A2,"0"), ...).
  • Duplicate keys: VLOOKUP returns only the first match. To get all matches, you need a more complex array formula or use FILTER.
  • Blank rows: Use QUERY with where Col1 is not null to exclude them.
  • Performance: Array formulas with VLOOKUP can slow down with large datasets. Limit the range (e.g., B2:B1000 instead of whole column) to improve speed.

Comparison with Excel’s Power Query

In Excel, you would use Power Query (Get & Transform Data) to merge tables with a proper join UI. Google Sheets lacks a direct equivalent, but you can use the QUERY approach or install an add-on like “Merge Sheets” for a graphical interface. For one-off joins, the formula method is fine; for recurring merges, consider using Google Apps Script to automate the process.

Frequently Asked Questions

Can I use JOIN in Google Sheets QUERY?

No, the QUERY language does not support a JOIN clause. You must use array formulas or VLOOKUP to combine tables manually.

How do I join two tables with different column names?

Use VLOOKUP with the matching key column. The lookup column in the second table must be the first column of the range you specify. If the key is not the first column, reorder the range or use INDEX with MATCH.

What is the difference between VLOOKUP and INDEX/MATCH for joining?

VLOOKUP is simpler but only searches the first column of the range. INDEX and MATCH allow you to search any column and return any column, making it more flexible. For joining, either works; VLOOKUP is usually easier to read.

Can I join more than two tables?

Yes, you can nest VLOOKUP or chain array formulas. For example, after joining table A and B, you can join the result with table C using another VLOOKUP on a new key. However, it gets messy; consider using Apps Script or a dedicated add-on for complex joins.

Does this work in Excel?

The formulas are similar, but Excel has XLOOKUP (in Excel 2021/365) which is more powerful. In older Excel, use VLOOKUP or INDEX/MATCH. The array formula syntax differs slightly (Ctrl+Shift+Enter in older versions).

Is there a way to join without formulas?

Yes, you can use Google Sheets’ built-in “Merge” feature under Data > Data cleanup, but it only merges columns, not rows. For true row-based joins, you need formulas or an add-on.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.