# Whenever there is now ID in MySQL show it to msg.debug

**URL:** <https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751>\
**Category:** General\
**Created:** [8 September 2021 10:16 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751 "2021-09-08T10:16:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![idlvpfk](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@idlvpfk](https://discourse.nodered.org/u/idlvpfk)\
**Post date:** [8 September 2021 10:16 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/1 "2021-09-08T10:16:12Z")

</div>

Hi guys,

And again I can't find proper solution for my scenario.  
I have succesfully established connection between node-red and MySQL , SELECT is working flawlessly, but I can't mind how to receive msg.debug whenever there is new INSERT into MySQL table.  
Each input has unique ID, so is it even possible to gather information as I want?  
For example:  
User A filled quiz which produced new ID in MySQL, when it happens node-red msg.debug says: 'hey , new entry with #ID' This checker can be time triggered , for example 2mins.

Cheers! 🙂

---

<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:** [8 September 2021 10:35 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/2 "2021-09-08T10:35:10Z")

</div>

Presumably it's not Node-Red that manages the INSERT, or you could use that flow to notify you of a new record.

Something like this should work.  
Maybe this query is more efficient - "select id from table\_name order by id desc limit 1"

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/631566359789b7a9a24d976c5b03bfc2b7aff2d2.jpeg)

---

<div class="post-metadata">

**Author:** ![idlvpfk](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@idlvpfk](https://discourse.nodered.org/u/idlvpfk)\
**Post date:** [8 September 2021 10:40 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/3 "2021-09-08T10:40:25Z")

</div>

I need to receive msg.payload notification only when new ID is created in MySQL! If ID, for example #ID4583 is the same, check it after 10mins again! If #ID4584 , msg.payload should notify me .  
Is it possible?

---

<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:** [8 September 2021 10:42 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/4 "2021-09-08T10:42:30Z")

</div>

Yes it is.

---

<div class="post-metadata">

**Author:** ![idlvpfk](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@idlvpfk](https://discourse.nodered.org/u/idlvpfk)\
**Post date:** [8 September 2021 10:48 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/5 "2021-09-08T10:48:18Z")

</div>

Can you help me to write this function?

---

<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:** [8 September 2021 10:49 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/6 "2021-09-08T10:49:51Z")

</div>

This is the way I'd do it. The third node is a Filter.

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/631566359789b7a9a24d976c5b03bfc2b7aff2d2.jpeg)  
Does it not work for you?

---

<div class="post-metadata">

**Author:** ![idlvpfk](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@idlvpfk](https://discourse.nodered.org/u/idlvpfk)\
**Post date:** [8 September 2021 11:05 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/7 "2021-09-08T11:05:04Z")

</div>

When i try to select , all seems to be working just fine!  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b164a963db397020e0ab945db0e529134d757243.png)

But when i use select max(id) im getting middle finger!  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/9/695a2506707f53760e45d60da4eeb1f69d50f21d.png)  
hmmmm... strange

Got it!  
Thanks mate, my problem is solved!  
Have a nice day!

---

<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:** [22 September 2021 11:05 UTC](https://discourse.nodered.org/t/whenever-there-is-now-id-in-mysql-show-it-to-msg-debug/50751/8 "2021-09-22T11:05:14Z")

</div>

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