Question about last insert id

Posts   
 
    
OSSistemes
User
Posts: 24
Joined: 20-Nov-2019
# Posted on: 24-Apr-2025 12:05:57   

Hi team

I have a question, when I save a new subentity with an autoincrement column, after insert query, orm send last_insert_id() query, my question is why??

when you send INSERT query with and autoincrement column, MYSQL return you on response the number(ID) assigned to this column, why is necessary to query again last_insert_id()???

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39861
Joined: 17-Aug-2003
# Posted on: 25-Apr-2025 08:52:32   

Because identity columns are seen as a column with a sequence and if you define a sequence in mysql you need the select statement to get the last inserted value from the sequence.

Frans Bouma | Lead developer LLBLGen Pro