Pacific-Design.com

    
Home Index

1. SQL

2. ON DUPLICATE KEY

SQL / ON DUPLICATE KEY /

Insert Table2 into Table1, update Table1 on duplicate key

INSERT INTO Table1 (id, title,dt)
  SELECT id, title, dt 
    FROM Table2 
    ON DUPLICATE KEY UPDATE 
      title=VALUES(title), 
      dt=VALUES(dt);