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;

获取最后的id 防止自增id过大

insert 条数 + update 条数 = 自增后的条数

http://stackoverflow.com/questions/13623258/insert-on-duplicate-key-update-with-last-insert-id
LAST_INSERT_ID 获取id

你可能感兴趣的:(INSERT ON DUPLICATE KEY UPDATE)