Is it possible to update the source table with the LAST_INSERT_ID from the target table?
INSERT INTO `target` SELECT `a`, `b` FROM `source`
The target table has an auto increment key id which I would like to store in the source table for further usage.
Would save me a lot of computing power if something like this would be possible :)
Immediately after executing:
INSERT INTO `target` SELECT `a`, `b` FROM `source`
Call an update on the source
table as below:
UPDATE `source`
SET field_name = LAST_INSERT_ID()
WHERE col_name_x = some_value_or_expression
Change column names and where conditions and then execute it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.