Skip to content

Instantly share code, notes, and snippets.

@jheth
Last active January 24, 2018 16:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jheth/6baa1b1123d79df3a45ed92095e808e3 to your computer and use it in GitHub Desktop.
sql update from sub-query
-- great way to batch update using a sub-query in the from clause
update category set catid=100
from (
select event.catid
from event
left join category cat on event.catid = cat.catid
where cat.catid is null
limit 1000
) eventcat
where category.catid = eventcat.catid
and catgroup='Concerts';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment