Created
June 26, 2015 12:30
-
-
Save achristodoulou/aa465abba3cba1dda633 to your computer and use it in GitHub Desktop.
Update multiple MySql records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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