Table of Contents
The Query function in Google Sheets allows users to join tables by combining data from multiple tables into one, making it easier to analyze and organize data. To join two tables using the Query function, users can specify the columns they want to include and apply different conditions or criteria to filter the data. This function is useful for combining data from different sources or tables within the same spreadsheet, saving time and effort in data analysis. By following a few simple steps, users can efficiently merge tables and access the combined data in a new table, making data management in Google Sheets more efficient and effective.
Google Sheets Query: Join Two Tables
Often you may want to use the QUERY() function in Google Sheets to join two tables together.
Unfortunately, a JOIN() function does not exist within the QUERY() function, but you can use the following formula as a workaround to join two tables together:
=ArrayFormula(
{
A2:B6,
vlookup(A2:A6,D2:E6,COLUMN(Indirect("R1C2:R1C"&COLUMNS(D2:E6),0)),0)
}
)
This particular formula performs a left join on the tables located in the ranges A2:B6 and D2:E6.
The following example shows how to use this formula in practice.
Example: Join Two Tables in Google Sheets
Suppose we have the following two tables in Google Sheets that contain information about various basketball teams:

We can use the following formula to perform a left join on the two tables and return one table that contains the team name, points, and assists for every team in the left table:
=ArrayFormula(
{
A2:B6,
vlookup(A2:A6,D2:E6,COLUMN(Indirect("R1C2:R1C"&COLUMNS(D2:E6),0)),0)
}
)The following screenshot shows how to use this formula in practice:

Notice that the result is one table that contains the team name, points, and assists for every team in the left table.
Note: If a team in the left table does not exist in the right table, a value of #N/A will be returned in the Assists column of the resulting table.
The following tutorials explain how to perform other common tasks in Google Sheets
Cite this article
stats writer (2024). How can I join two tables in Google Sheets using the Query function?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-join-two-tables-in-google-sheets-using-the-query-function/
stats writer. "How can I join two tables in Google Sheets using the Query function?." PSYCHOLOGICAL SCALES, 26 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-join-two-tables-in-google-sheets-using-the-query-function/.
stats writer. "How can I join two tables in Google Sheets using the Query function?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-join-two-tables-in-google-sheets-using-the-query-function/.
stats writer (2024) 'How can I join two tables in Google Sheets using the Query function?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-join-two-tables-in-google-sheets-using-the-query-function/.
[1] stats writer, "How can I join two tables in Google Sheets using the Query function?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I join two tables in Google Sheets using the Query function?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
