Wednesday 4 November 2020

MySQL LAST_INSERT_ID() Function

 SELECT LAST_INSERT_ID();

 

 

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

The solution is something like this:

UPDATE formulare SET EV_id=LAST_INSERT_ID(59), EV_status=5 WHERE EV_id=57 AND ID_uziv=12;SELECT LAST_INSERT_ID();

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

Otherwise you should do a query like:

UPDATE formulare SET key_col = LAST_INSERT_ID(key_col), EV_id=59, EV_status=5 WHERE EV_id=57 AND ID_uziv=12;SELECT LAST_INSERT_ID();


No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive