Skip to content

Instantly share code, notes, and snippets.

@achristodoulou
Created June 26, 2015 12:30
Show Gist options
  • Save achristodoulou/aa465abba3cba1dda633 to your computer and use it in GitHub Desktop.
Save achristodoulou/aa465abba3cba1dda633 to your computer and use it in GitHub Desktop.
Update multiple MySql records
create temporary table tmp(
client_id INT(11),
amount char(2)
);
INSERT INTO tmp
SELECT client_id, amount + 10
FROM clients;
UPDATE clients as r
INNER JOIN tmp c ON c.client_id = r.client_id
SET r.amount = c.amount
WHERE c.amount is not null;
DROP TABLE IF EXISTS tmp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment