Withdata Software

Upsert a row Into Mysql Table

In Mysql, if you want to either updates or inserts a row in a table, depending if the table already has a row that matches the data, you can use “ON DUPLICATE KEY UPDATE”.

INSERT INTO employees(id, name, hire_date ) 
VALUES (1, 'John', '2016-11-29' ) 
ON DUPLICATE KEY UPDATE name='john', hire_date='2016-11-29'

In SQL Server, http://www.withdata.com/ad/sql-server/replace-update-or-insert-a-row-into-sql-server-table.html

In Oracle, http://www.withdata.com/ad/oracle/replace-update-or-insert-a-row-into-oracle-table-merge-into.html

In DB2, http://www.withdata.com/ad/db2/replace-update-or-insert-a-row-into-db2-table-merge-into.html

In Sqlite, http://www.withdata.com/ad/sqlite/replace-update-or-insert-a-row-into-sqlite-table.html

Some MySQL tools you can try: https://www.withdata.com/mysql/