Answer the question
In order to leave comments, you need to log in
How to get id when doing UPDATE request?
When executing an INSERT query, you can get the id of the last record through the mysql_insert_id () function, but when executing an UPDATE, the auto-increment mechanism is not affected and the function returns 0. Google on this problem issues dances with a tambourine around SELECT and additional columns. Is there any nice solution to this problem? ...or some other function that I didn't find?
Answer the question
In order to leave comments, you need to log in
When executing an INSERT query, you can get the id of the last record using the mysql_insert_id() function
SELECT MAX(id) FROM ...
In general, the answer has already been given, but it is incorrect.
That's how you can.
UPDATE /* */ SET `id` = LAST_INSERT_ID(`id`), /* */
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question