Last active
January 24, 2018 16:00
-
-
Save jheth/6baa1b1123d79df3a45ed92095e808e3 to your computer and use it in GitHub Desktop.
sql update from sub-query
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
| -- 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