Answer the question
In order to leave comments, you need to log in
How to make SELECT LAST_INSERT_ID() as id work?
SELECT LAST_INSERT_ID() as id
returns 0 all the time, although it should return the ID of the newly added entry
Answer the question
In order to leave comments, you need to log in
Firstly, the request is not complete, the table is not specified, and secondly, if an auto index is used, then it is easier to make a selection by id.
For example,
SELECT id FROM tbl_name ORDER BY id DESC LIMIT 0, 1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question