Skip to content

Instantly share code, notes, and snippets.

@samuelbalogh
Last active June 19, 2018 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelbalogh/050b2cf5942f90757690ab161a1e7bef to your computer and use it in GitHub Desktop.
Save samuelbalogh/050b2cf5942f90757690ab161a1e7bef to your computer and use it in GitHub Desktop.
WITH invoices_for_cancelled_projects AS
(SELECT * FROM invoices, projects
WHERE projects.status = 'cancelled'
AND invoices.project_id = projects.id)
UPDATE invoices_for_cancelled_projects
SET invoices.status = 'cancelled'
FROM invoices_for_cancelled_projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment