# NR and Postgres query

**URL:** <https://discourse.nodered.org/t/nr-and-postgres-query/32043>\
**Category:** General\
**Created:** [26 August 2020 14:11 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043 "2020-08-26T14:11:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![little\_rich](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@little\_rich](https://discourse.nodered.org/u/little_rich)\
**Post date:** [26 August 2020 14:11 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043/1 "2020-08-26T14:11:45Z")

</div>

Hi,  
I have a database with the following columns...  
id t\_1 t\_2 t\_3 ... t\_(n)

I have a function which queries t\_1 based on a row id and the returned message.payload looks like this...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4fb3c4b8bccf104453c969a9b3b6e396fd8f2f95.png)

I am trying to get a function that detects if t\_1 is null as per the below...

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/e/ce1a17efa7e3103912c983c1772edb5e0f5a0394.png)

I'm sure my problem is in Line 2 but I am not sure how to drill down to the point where t\_1 is null

Have also tried the switch node as my result is either null or not but feel my issue is kind of the same regardless, I have a syntax error.

Any ideas greatly appreciated

---

<div class="post-metadata">

**Author:** ![little\_rich](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@little\_rich](https://discourse.nodered.org/u/little_rich)\
**Post date:** [26 August 2020 14:21 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043/2 "2020-08-26T14:21:06Z")

</div>

Ohhh, I think msg.object might have found the null answer. I'm now so tired I will have to check this tomorrow, sorry if I wasted anyones time.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [26 August 2020 19:17 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043/3 "2020-08-26T19:17:40Z")

</div>

```auto
if (msg.payload.rows[0].t_1 === null )

```

You can always click on " **Copy Path**" at the position of the value if you are uncertain

![Untitled-1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f273d6793c90ee082950ac6c7935eb9bd1e00d09.jpeg)

---

<div class="post-metadata">

**Author:** ![little\_rich](https://avatars.discourse-cdn.com/v4/letter/l/839c29/32.png) [@little\_rich](https://discourse.nodered.org/u/little_rich)\
**Post date:** [27 August 2020 07:31 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043/4 "2020-08-27T07:31:22Z")

</div>

Ooh, fantastic. I didn't know that, thank you so much.

I haven't fixed my problem but this should help me.  
Cheers

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [26 October 2020 07:31 UTC](https://discourse.nodered.org/t/nr-and-postgres-query/32043/5 "2020-10-26T07:31:33Z")

</div>

Closed on 26 October 2020 07:31 UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
