# Combine a message from mqtt and a select result from db

**URL:** <https://discourse.nodered.org/t/combine-a-message-from-mqtt-and-a-select-result-from-db/18141>\
**Category:** Dashboard\
**Created:** [19 November 2019 10:13 UTC](https://discourse.nodered.org/t/combine-a-message-from-mqtt-and-a-select-result-from-db/18141 "2019-11-19T10:13:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [19 November 2019 10:13 UTC](https://discourse.nodered.org/t/combine-a-message-from-mqtt-and-a-select-result-from-db/18141/1 "2019-11-19T10:13:59Z")

</div>

Hi,  
I am receiving a message on mqtt which I get as variable using a function " var status = msg.payload" but I am not able (i don t know how to do) to get in same function a value from an sql select and compare it to my status. I wasn t able to find such an example...if anyone can help me I would be very gratefull

thank you

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 November 2019 10:31 UTC](https://discourse.nodered.org/t/combine-a-message-from-mqtt-and-a-select-result-from-db/18141/2 "2019-11-19T10:31:03Z")

</div>

There is an example in the cookbook that shows how to combine messages from two sources into one message so that you can use them together.  
[https://cookbook.nodered.org/basic/join-streams](https://cookbook.nodered.org/basic/join-streams)

---

<div class="post-metadata">

**Author:** ![lucianv](https://avatars.discourse-cdn.com/v4/letter/l/cab0a1/32.png) [@lucianv](https://discourse.nodered.org/u/lucianv)\
**Post date:** [19 November 2019 10:53 UTC](https://discourse.nodered.org/t/combine-a-message-from-mqtt-and-a-select-result-from-db/18141/3 "2019-11-19T10:53:11Z")

</div>

Thank you very much, not sure how i was not able to find it but was exactly what i needed  
Thanks a lot again
