第一种方式:
INSERT INTO t_yf_token(
id,token,apply_time)
VALUES(
'1' ,
'新人1' ,
NOW())
ON DUPLICATE KEY UPDATE
id = VALUES(id) ,
token = VALUES(token),
apply_time = VALUES(apply_time);
存在则忽略,不存在则插入:
INSERT IGNORE INTO xx (field1,field2) VALUES (
VALUES1,VALUES2
)
INSERT IGNORE INTO t_xx (xx) SELECT xx FROM dual;