作者:蒓子2502883107 | 来源:互联网 | 2024-10-16 11:06
INSERTINTOnewest_log_operation(ACTION,OPERATION,KEY_VALUE,BUS_KEY,CONTENT,USER_ID,VERSIO
INSERT INTO newest_log_operation(
ACTION, OPERATION, KEY_VALUE, BUS_KEY, CONTENT, USER_ID, VERSION, MODULE,CREATE_TIME)
VALUES (:action, :operation, :keyValue, :busKey, :content, :userId, 1, :module,now())
ON DUPLICATE KEY UPDATE
ACTION = VALUES(ACTION),OPERATION = VALUES(OPERATION),BUS_KEY = VALUES(BUS_KEY),COnTENT= VALUES(CONTENT),
USER_ID = VALUES(USER_ID),VERSION = VERSION + 1,CREATE_TIME = VALUES(CREATE_TIME);
1.ON DUPLICATE KEY UPDATE:表示唯一键重复或者主键重复
2.VALUES (:action, :operation, :keyValue, :busKey, :content, :userId, 1, :module,now()):假如不存在值,则新增记录,并且赋值
3.ACTION = VALUES(ACTION),OPERATION = VALUES(OPERATION),BUS_KEY = VALUES(BUS_KEY),COnTENT= VALUES(CONTENT),
USER_ID = VALUES(USER_ID),VERSION = VERSION + 1,CREATE_TIME = VALUES(CREATE_TIME):表示假如唯一健或者主键已经存在,则更新部分字段.