How to retry ID from MySQL of last INSERT INTO

I'm able to store int MySQL compiling msg.topics with insert into ... SQL command, but I need to get the ID of this transaction.

How to do?

Thanks, Fabrizio

What do you mean by ID?

You're right, I wasn't precise.
In my table, I have a primary key with auto-increment enabled, so when I make "insert into" this field is automatically created.
I want to retrieve it, contextually with insert command.

I'm not sure I can use :
SELECT max(id) FROM mytable;

because I have other asynchronous insertion, and the risk is to get bad id from a sequence like this:

  1. my Insert
  2. other asynchronous INSERT
  3. max(id) FROM ...

In this case, the returned id is the one of asynchronous insertion.

After some mistakes, I've found my solution here.

Just, I have to find the exact means of all fields, but what I need is on msg.payload.insertID.

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