update a set counts=(select count(1) from b where a.id=b.aid ) from a
谢谢,问题可解决!不过,为什么这样更新不是所有的counts值都一样的呢?
A[信息分组表]字段:id,counts[记录B表中Aid与id值相等的总数] B[详细信息表]字段:id,Aid[Aid=A.id] update a set counts=b.counts from a,(select Aid,count(1) as counts from b) b where a.aid=b.aid
from a
A[信息分组表]字段:id,counts[记录B表中Aid与id值相等的总数]
B[详细信息表]字段:id,Aid[Aid=A.id] update a set counts=b.counts
from a,(select Aid,count(1) as counts from b) b
where a.aid=b.aid