Skip to content
Advertisement

LAST_INSERT_ID not working on UPDATE

if I use this SQL:

JavaScript

I will get 0 as last insert id. I’m using php mysqli_insert_id and here is said that:

JavaScript

my table formualre has auto increment column, so I don’t know wher the problem is

Advertisement

Answer

LAST_INSERT_ID() won’t work if no new auto increment value was created.

The solution is something like this:

JavaScript

Note: I guess, that EV_id is the auto_increment primary key.

Otherwise you should do a query like:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement