Skip to content

Instantly share code, notes, and snippets.

@ddbs
Last active August 29, 2015 13:56
Show Gist options
  • Save ddbs/9239403 to your computer and use it in GitHub Desktop.
Save ddbs/9239403 to your computer and use it in GitHub Desktop.
sql: insert on duplicate key update (update only specific columns if a unique key already exists; insert new rows if unique key does not exist)
INSERT INTO _customers (`User ID`, Username, `Billing: Full Name` )
SELECT `User ID`, Username, `Billing: Full Name`
FROM _customers_import
ON DUPLICATE KEY UPDATE Username=values(Username), `Billing: Full Name`=values(`Billing: Full Name`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment