批量Update,从另一个表中取关联的字段对应的值,来更新当前的表的joinCount值
UPDATE EventGroup g SET joinCount =(SELECT b.counts FROM (SELECT eventGroupId,SUM(1) AS counts FROM EventGroupMember WHERE groupRoleId<4 AND (memberStatus=0 OR memberStatus=3) GROUP BY eventGroupId) b WHERE b.eventGroupId=g.eventGroupId)
WHERE EXISTS(SELECT 1
FROM (SELECT eventGroupId,SUM(1) AS counts FROM EventGroupMember WHERE groupRoleId<4 AND (memberStatus=0 OR memberStatus=3) GROUP BY eventGroupId) b
WHERE b.eventGroupId=g.eventGroupId
);