批量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 );