I have table like this:
id business_id path photo
1 11 1.jpg 0
2 11 2.jpg 0
3 15 1.jpg 0
4 15 3.jpg 0
5 15 4.jpg 0
6 21 scan1.jpg 0
7 21 scan2.jpg 0
8 22 1.jpg 1
....
I want to update table so that for each business lets say in above scenario for business 11. one of the path should have photo set to 1.
If photo is already set to 1 (like for business_id = 22) above it should not change that.
I think below query will work for 1 business_id at a time:
Update business
set photo = 1
where id = 11 limit 1
But my question is how can I run this in a batch? So I can update all at once.