Last active
August 9, 2018 10:41
-
-
Save baybatu/0c94bec3e8804eb2ff6ed3ce6140a4b0 to your computer and use it in GitHub Desktop.
Update rows using sub select query in PostgreSQL
This file contains 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
UPDATE cars | |
SET model = subNewCarsTable.newModelName | |
FROM (SELECT | |
nc.id AS carId, | |
nc.model AS newModelName | |
FROM new_cars nc | |
WHERE year=2018) subNewCarsTable | |
WHERE subNewCarsTable.carId = cars.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment