# How to get data from MYSQL

**URL:** <https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561>\
**Category:** Dashboard\
**Created:** [16 December 2020 03:04 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561 "2020-12-16T03:04:40Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [16 December 2020 03:04 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/1 "2020-12-16T03:04:41Z")

</div>

hello, my name is Arwin, I want to retrieve data in my MySQL database, but the results are like that? how to take only the values ​​at the "suhu" only? thank you  
my Query

> msg.topic = "SELECT suhu FROM ph ORDER BY timestamp DESC LIMIT 1";

![Prob1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4d055984b8ee44f4a6cef3020fde91fb1d15fc73.png)

 ![Prob2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0ab8d0ec6110d5052dee973c380bd83450637a35.png)

---

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [16 December 2020 03:09 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/2 "2020-12-16T03:09:19Z")

</div>

i want the UI Text to be "Suhu : 0", is there any suggestion for me?

---

<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:** [16 December 2020 08:18 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/3 "2020-12-16T08:18:23Z")

</div>

The first thing to do in a situation like this is to add a debug node to see what information is coming from the database node. Then you need to work out how to extract the particular data that you need.

---

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [16 December 2020 09:40 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/4 "2020-12-16T09:40:08Z")

</div>

![Debug](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/370466b5bb6c6d0958ad049aa3fc656856239030.png)  
This is my debug from MySQL node

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [16 December 2020 09:54 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/5 "2020-12-16T09:54:28Z")

</div>

Hover your mouse over the object and you will see some options.  
 ![Screen Shot 2020-12-16 at 4.51.46 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/d/ed74b23012ce1480c0d8e68b6b6decb4e38c2311.png)  
Clicking on the `>_` will copy the path to the item  
`payload[0].suho`  
which you can use to access that item

---

<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:** [16 December 2020 11:21 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/6 "2020-12-16T11:21:54Z")

</div>

In particular, for a ui text node you can put in the Value Format field  
`{{msg.payload[0].suho}}`

---

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [17 December 2020 03:03 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/7 "2020-12-17T03:03:43Z")

</div>

its work, but if I add the data "suhu" then the data in the UI Text will not update. How can I update the data?

---

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [17 December 2020 03:06 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/8 "2020-12-17T03:06:05Z")

</div>

if I have 2 data, how do I make the UI Text update automatically? does not change the payload [0].suhu to payload [1].suhu

---

<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:** [17 December 2020 07:36 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/9 "2020-12-17T07:36:34Z")

</div>

Again the first thing to do is to send the data to a debug node and see what is there.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [17 December 2020 09:58 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/10 "2020-12-17T09:58:51Z")

</div>

@marwinwijaya

> [@marwinwijaya](#):
>
> msg.topic = "SELECT suhu FROM ph ORDER BY timestamp DESC LIMIT 1

how do you get two outputs when you have a 'LIMIT 1' in your sql statement? Or have you changed the statement? Changing the SQL is important information to let us know

---

<div class="post-metadata">

**Author:** ![marwinwijaya](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marwinwijaya/32/23923_2.png) [@marwinwijaya](https://discourse.nodered.org/u/marwinwijaya)\
**Post date:** [19 December 2020 09:35 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/11 "2020-12-19T09:35:59Z")

</div>

Thanks you, @Colin! @zenofmud

---

<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:** [18 January 2021 09:36 UTC](https://discourse.nodered.org/t/how-to-get-data-from-mysql/37561/12 "2021-01-18T09:36:03Z")

</div>

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