I am trying to merge the below 2 Update statements into a single query, since they are both working on the same tables.
My school.present count is updated based on count of children.attendance=PRESENT status
UPDATE school s SET s.present=(SELECT count(children.id) FROM children c
WHERE c.school_id =s._id AND c.attendance='PRESENT')
Similarly, school.danced count is updated based on count of children.activity=DANCE status
UPDATE school s SET s.danced=(SELECT count(children.id) FROM children c
WHERE c.school_id =s._id AND c.activity='DANCE')
Is it possible to merge the two to save on the number of queries ?
My current attempt is merge the two into the following - but I think this will result in the same two queries as above
UPDATE school s SET
s.danced=(SELECT count(children.id) FROM children c
WHERE c.school_id =s._id AND c.activity='DANCE'),
s.present=(SELECT count(children.id) FROM children c
WHERE c.school_id =s._id AND c.attendance='PRESENT')
Is there a better way to achieve this or is the above as efficient as it can get ?