Created
September 26, 2019 22:08
-
-
Save bryaneaton/24b799a3ac1b63bafe3831f95ea26d32 to your computer and use it in GitHub Desktop.
update multiple tables - Postgres
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
WITH src AS ( | |
UPDATE serial_rate | |
SET rate = 22.53, serial_key = '0002' | |
WHERE serial_key = '002' AND id = '01' | |
RETURNING * | |
) | |
UPDATE serial_table dst | |
SET serial_key = src.serial_key | |
FROM src | |
-- WHERE dst.id = src.id AND dst.serial_key = '002' | |
WHERE dst.id = '01' AND dst.serial_key = '002' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment