ON DUPLICATE KEY UPDATE can achieve the following purposes:
Insert a record into the database:
If the primary key value/UNIQUE KEY of the data already exists in the table, perform the update operation, that is, the operation after the UPDATE.
Otherwise insert a new record.
例子:
INSERT INTO `gm_ban_login` (`sid`, `expire_time`, `reason`, `gm_user`, `operate_time`) VALUES ( 150, 0, '111', '222', 0) ON DUPLICATE KEY UPDATE `expire_time`=0, `reason`='111', `gm_user`='222', `operate_time`=0;