INSERT ON DUPLICATE KEY UPDATE

INSERT INTO table (a, b, c) VALUES (1, 2, 3)
  ON DUPLICATE KEY UPDATE id = LAST_INSERT_ID(id), c = 3;

get the last id to prevent the self-incrementing id from being too large

Number of inserts + number of updates = The number of post incrementshttp:

//stackoverflow.com/questions/13623258/insert-on-duplicate-key-update-with-last-insert-id
LAST_INSERT_ID get id

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327038963&siteId=291194637