In this article:

How to Select Multiple Columns through SQL Query in Google Sheets

May 8, 2024
>Click here to Import a MYSQL Database to a Lido Spreadsheet

Querying only becomes effective if we see the associated information in our query results. This is possible if we can select multiple columns through SQL queries.

Is it possible in Google Sheets? Yes!

This tutorial will tackle how it is done via the QUERY function and its associated SQL in Google Sheets.

How to Select Multiple Columns Using SQL Query

When you want to list down multiple columns for each entry but apply a single criterion applied to one column, you simply list down the columns to select then followed by the condition.  For our example, we have added a table containing U.S. states’ etymology on one sheet.

U.S. state names etymology sheet. Data from Wikipedia article on U.S. state names etymology.
U.S. state names etymology sheet. Data from Wikipedia article on U.S. state names etymology!


What if we want to display the state name column and the language of origin column in a separate sheet, without any criterion to use? We use the following query:

select A, D

With this, we'll have to place it in Google Sheets' QUERY function with the format:

=query([range],"[SQL query]'")

And we get the following result:

Query result listing the states and the language of origin of their names.
Query result listing the states and the language of origin of their names. 

The same syntax will work if you add conditions to the query. For example, we wish to filter our initial results by adding the column for the year the name was first attested and by selecting states whose names were first attested before 1800. Our query will now look like this:

select A, C, D where C < 1800

With this, we'll have to place it in Google Sheets' QUERY function with the format:

=query([range],"[SQL query]'")

And our result will look like this:

Query result listing the states, the year their name was first attested, and language of origin of their names. All the listed states have their name first attested before 1800.
Query result listing the states, the year their name was first attested, and language of origin of their names. All the listed states have their name first attested before 1800.


You would naturally ask whether two or more criteria can be combined in a single query. The answer is yes! You can read more about it here.

Can we change the order the selected columns appear? Absolutely! Just arrange the column list in your preferred order. If we make the following query:

select D, C, A 

With this, we'll have to place it in Google Sheets' QUERY function with the format:

=query([range],"[SQL query]'")

The result will look like this: 

Query result listing the states, the year their name was first attested, and language of origin of their names. The order however was flipped: the language of origin of their names came first, then the year first attested, and finally the state name.
Query result listing the states, the year their name was first attested, and language of origin of their names. The order however was flipped: the language of origin of their names came first, then the year first attested, and finally the state name.

Limitations & An Alternative Method...

A complex combination of multiple columns and criteria is needed to get refined search results, but even then, you still have to read the entries one-by-one to get meaningful analysis, to ultimately make great decisions for your business.

I have one suggestion for you to do so without having to do the laborious job of querying large databases: consider trying Lido. With a few clicks on your laptop, you can now access all the relevant metrics without going through the hassle of accessing the SQL databases of your eCommerce platforms and then coding the formulas to process them. Let our platform do it all for you!


Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->