INSERT INTO library_reader_mapping (reader_id_card,library_code,borrow_card, create_time, active_time, gate_in_time) VALUES (?, ?,?, now(), now(),now()) ON DUPLICATE KEY UPDATE gate_in_time=now()
还可以插入多行:
INSERT INTO t1 (a,b,c) VALUES (1,2,3),(4,5,6)
ON DUPLICATE KEY UPDATE c=VALUES(a)+VALUES(b);
注意:
如果行作为新记录被插入,则受影响行的值显示1;如果原有的记录被更新,则受影响行的值显示2。