MySQL Forums
Forum List  »  Newbie

Re: use max(id) from table to insert in other table
Posted by: Peter Brawley
Date: May 16, 2018 01:48PM

> should I mark this as "solved".

No.

...(select max(id) from mqtt_connection)... is not guaranteed to return the last mqtt_connection.id created on the current connection. It will return the biggest id in the period, which may be from another connection.

To guarantee you have the last id created in the current connection, use last_insert_id() instead, as Phillip suggested.

Options: ReplyQuote


Subject
Written By
Posted
Re: use max(id) from table to insert in other table
May 16, 2018 01:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.