关于SQL 两表 count

初学SQL,遇到一个问题

表一
组名 人数
表二
人名 参加小组的组名
现在要用COUNT统计表二的各个组的人数并赋值给表一相应的人数一栏

update 表一 a set a.人数 =(select b.num from
(select 参加小组的组名,count(*) as num from 表二 group by 参加小组的组名) b where a.组名=b.参加小组的组名)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-05-16
update 表一 a set a.人数 =(select count(*) as num from 表二 b where b.参加小组的组名=a.组名) where a.组名=b.参加小组的组名
相似回答