Get all the column value of a google sheet and add all values inside a mySQL query

Hi Team,

Is there a way how to get all the column value of a google sheet and add all values inside a mySQL query.

Sincerely,

OBI

Hi @daniel.o, you can use Object.keys() to read get just column names after reading from a Google Sheet. For example:

For a spreadsheet like this:

image

The workflow would return this:

You can use this as the base for your SQL query, the exact steps to build the full query will obviously depend on the query you’d like to have.

Thanks for the response. How do I use those output inside mySQL query? Can you provide a flow? Thanks

I cannot because I don’t know what you’re trying to achieve unfortunately.

This one: SELECT * FROM db_table WHERE ID=‘Gsheet_Column_Values’

Gsheet_Column_Values were all ID values.

So, you simply want to run a query for each of the items in your Google Sheet?

Yes exactly. If data found update that row in mySQL. If not add new row to MySQL.

Okay, so your question is not actually related to Google Sheets, but simply about running a MySQL query for each item in n8n?

This should work like so:

In this example I am using an expression of SELECT * FROM users WHERE id = {{$json["ID"]}}; in my query. Now the ID value of each item arriving on the MySQL node is being used.

So, for a table like below:

image

The above example workflow returns a result like this: