Skip to content

Instantly share code, notes, and snippets.

@RaidoS
Created May 24, 2019 09:13
Show Gist options
  • Save RaidoS/c0e0171ed8fabae6c7cb50717942d266 to your computer and use it in GitHub Desktop.
Save RaidoS/c0e0171ed8fabae6c7cb50717942d266 to your computer and use it in GitHub Desktop.
Postgresql script example UPDATE table with INNER JOIN
WITH a AS (
SELECT sportsmen_id FROM chalenge_results r
INNER JOIN
chalenge_chalengesporter s
ON r.sportsmen_id = s.id
WHERE date_part('year', s.date_req) = 2017
)
UPDATE chalenge_results as c
SET chalenge_id = 2
FROM a WHERE c.sportsmen_id = a.sportsmen_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment