How to insert variable in postgres query

Describe the issue/error/question


I tried 10 different things, but I can’t manage to retrieve variables in my query:
The query : SELECT 'hello' as col1, $1 as col2

The variable : {{$json[“Votre email”]}}

I get the values from a google sheets.

What I’m doing wrong ?



Please share the workflow

Share the output returned by the last node

each row =
  "col1": "hello",
  "col2": null

Information on your n8n setup

  • n8n version: Version 1.6.0 (1.6.0)
  • Database you’re using (default: SQLite):
  • Running n8n with the execution process [own(default), main]:
  • Running n8n via [Docker, npm,, desktop app]: desktop

Hi @tthias

Please share your worklow. You can simply select all nodes and paste it into a message. Please keep in mind to use the pre formatted text option.

1 Like

Hi @tthias, in your Postgres node you’d simply specify the field name rather than the value of your parameter. So if your Google Sheet node returns data with a key (or column headers if you like) of col1, you would use col1 as the value in Query Parameters. Like so:

Hope this helps! Let me know if you run into any problems with this.

1 Like

Hey thanks for your reply !

That’s working perfectly !

I was doing the following:

Instead of just typing the column name.



1 Like

You’re most welcome, glad to hear this works for you!

And what if I want to use values from different nodes as query parameters ?
Do I need to create a node to format the input with all the required values and put it just before the postgres query node ?

Yes, a typical approach would be a Set node in front of nodes processing incoming data “as is”. This allows you to define the exact fields you’d like to have using expressions which in turn can reference data from a previous node.

The expression editor comes with a little browser so you don’t have to write simple expressions manually. Simply select the node you want to read data from and click on the respective field name: