# How to use output parameter from webhook node in postgres query?

**URL:** <https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394>\
**Category:** Questions\
**Created:** [November 25, 2021, 4:28am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394 "2021-11-25T04:28:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhanya\_V\_Sagar](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dhanya_v_sagar/32/2896_2.png) [@Dhanya\_V\_Sagar](https://community.n8n.io/u/Dhanya_V_Sagar)\
**Post date:** [November 25, 2021, 4:28am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/1 "2021-11-25T04:28:00Z")

</div>

Hi,

I am working on a workflow to display the tables and the data inside a table from postgres database. The objective is to receive the schema name and table name from postman (will pass these values as Params in the GET request) and to use these values in the query.

eg: If I want to run the query select \* from information\_schema.tables where table\_schema=‘schema’ , I have to receive the schema-name from postman.

How can I achieve this in n8n. Can I utilize the query parameter feature of the node?

I have my workflow added as well.

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [November 25, 2021, 5:34am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/2 "2021-11-25T05:34:49Z")

</div>

Hey @Dhanya_V_Sagar,

Hope you’re doing well 🙂

You can use the Expression Editor to use the values you pass with the query parameters. The expression for the query can be as follow:

```auto
select * from {{$json.table}}.tables where table_schema='{{$json.schema}}'

```

Hope this is what you’re looking for. Let us know if you need more help 🙂

---

<div class="post-metadata">

**Author:** ![Dhanya\_V\_Sagar](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dhanya_v_sagar/32/2896_2.png) [@Dhanya\_V\_Sagar](https://community.n8n.io/u/Dhanya_V_Sagar)\
**Post date:** [November 25, 2021, 6:20am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/3 "2021-11-25T06:20:22Z")

</div>

Hi,

Thank you for the quick response.

select \* from {{$node[“Webhook”].json[“query”][“table”]}}.tables  
select \* from {{$node[“Webhook”].json[“query”][“table”]}}

I had tried these expressions before but it displays errors

```auto
error: syntax error at or near "."

```

and

```auto
error: syntax error at or near ";"

```

respectively.

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 25, 2021, 7:46am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/4 "2021-11-25T07:46:23Z")

</div>

This would be PostgreSQL complaining about some malformed query. Which values would `{{$node["Webhook"].json["query"]["table"]}}` have in your case?

---

<div class="post-metadata">

**Author:** ![Dhanya\_V\_Sagar](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dhanya_v_sagar/32/2896_2.png) [@Dhanya\_V\_Sagar](https://community.n8n.io/u/Dhanya_V_Sagar)\
**Post date:** [November 25, 2021, 8:10am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/5 "2021-11-25T08:10:39Z")

</div>

The node contains the name of table.

 ![2021-11-25 (3)](https://europe1.discourse-cdn.com/n8n/original/2X/a/a3d769e1a50e4e1538b766bc58259f0bc2bdc66c.png)

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 25, 2021, 8:24am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/6 "2021-11-25T08:24:58Z")

</div>

So an expression like this would be working in principle if temperature2 is a table in the current schema:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/b/b84551cd6aa513ba71a98b8105ee0583dd8d40ba.png)

What I suspect is happening here is that your first PostgreSQL node returns more than one item, meaning your expression won’t work anymore beyond the first item (since your are referring to items from the Webhook node which has only one item).

So you’d need to find out what you want to do here. If the second PostgreSQL node (“Postgres1”) only needs to run once (for the first item), just enable the respective setting:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/a/aa611b36230e1b2d5fb3f5c548d332b1e6f3e032.png)

If you want it to use each input from the first PostgreSQL node (“Postgres”), you’d need to make sure your expressions refers either to its own input data or to a node with the same number of items. For example like so:

 ![image](https://europe1.discourse-cdn.com/n8n/original/2X/0/09f6502d5fba9cf4d61a31c8665b5fcb683e7c5a.png)

---

<div class="post-metadata">

**Author:** ![Dhanya\_V\_Sagar](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/dhanya_v_sagar/32/2896_2.png) [@Dhanya\_V\_Sagar](https://community.n8n.io/u/Dhanya_V_Sagar)\
**Post date:** [November 25, 2021, 9:44am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/7 "2021-11-25T09:44:00Z")

</div>

Hi.  
Thank you for the detailed explanation. I have enabled the execute once option and it works fine.

I have one more doubt. Say I want to choose a value from the input data of the node, like the image you have shared (you have selected migration). The input data is displaying only the first row , with its column values. If I want to select data from some other row, how can I achieve this (say row num 3) ?

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [November 25, 2021, 9:47am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/8 "2021-11-25T09:47:32Z")

</div>

This is not currently possible through the expression editor as it just previews the first item. You could manually write an expression including [$item](https://docs.n8n.io/nodes/n8n-nodes-base.function/#method-item-index-number-runindex-number) to reference a specific item though.

---

<div class="post-metadata">

**Author:** ![d4dilip](https://avatars.discourse-cdn.com/v4/letter/d/e0b2c6/32.png) [@d4dilip](https://community.n8n.io/u/d4dilip)\
**Post date:** [June 25, 2025, 11:36am UTC](https://community.n8n.io/t/how-to-use-output-parameter-from-webhook-node-in-postgres-query/9394/9 "2025-06-25T11:36:30Z")

</div>

Here is the solution . use only variable name and not the expression

> [@Query parameters not working with Postgres](http://community.n8n.io/t/query-parameters-not-working-with-postgres/17203/2):
>
> Hi @Edward, welcome to the community! n8n would populate the query parameters using incoming data. So the Query Parameters field expects the name of one (or more) incoming fields like so: Workflow: In this example using a parameter wouldn’t make much sense, but it becomes more useful if you need to run queries for more than one incoming item slight_smile Hope this makes sense and helps!
