# Graphing temp and humidity from MariaDB

**URL:** <https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402>\
**Category:** General\
**Created:** [19 December 2022 00:37 UTC](https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402 "2022-12-19T00:37:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![HobbyFarmer](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HobbyFarmer](https://discourse.nodered.org/u/HobbyFarmer)\
**Post date:** [19 December 2022 00:37 UTC](https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402/1 "2022-12-19T00:37:01Z")

</div>

As some of my other posts mentioned I am stepping my way through a smart home build. Currently I have Arduinos sending temp and humidity to MariaDB on my Pi. I am pulling it back into NR and graphing it. However I would like to only pull partial amounts of this back like the last 100 points. Right now I am using a select query.

```auto
msg.topic = "SELECT * FROM houseTable;"

return msg;

```

How do I select the last 100 entries in that table.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [19 December 2022 01:30 UTC](https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402/2 "2022-12-19T01:30:59Z")

</div>

SELECT \* FROM houseTable LIMIT 100 will probably give you the first 100 records.

SELECT \* FROM houseTable ORDER BY key\_field ASC LIMIT 100 will definitely give you the first 100 records.

SELECT \* FROM houseTable ORDER BY key\_field DESC LIMIT 100 will give you the last 100 records but in descending order.

SELECT \* FROM (SELECT \* FROM houseTable h ORDER BY h.key\_field DESC limit 100) a ORDER BY a.key\_field ASC should give you the last 100 records in ascending order.

That's how I learned to do it, there may well be simpler syntax available now (hmm, SQL, simpler syntax? Not likely!)

---

<div class="post-metadata">

**Author:** ![HobbyFarmer](https://avatars.discourse-cdn.com/v4/letter/h/779978/32.png) [@HobbyFarmer](https://discourse.nodered.org/u/HobbyFarmer)\
**Post date:** [9 January 2023 05:32 UTC](https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402/3 "2023-01-09T05:32:25Z")

</div>

Thanks, much appreciated! Still haven't had a chance to give it a try. Been BUSY!

---

<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:** [10 March 2023 05:33 UTC](https://discourse.nodered.org/t/graphing-temp-and-humidity-from-mariadb/72402/4 "2023-03-10T05:33:20Z")

</div>

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