update Album set Num=y.Num
from Album x join
(select a.AlbumID,COUNT(*) as Num from Photo a join Album b
on a.AlbumID=b.AlbumID group by a.AlbumID) y
on x.AlbumID=y.AlbumID
联合更新语句,根据photo中的数量更新相册表Num列,布布扣,bubuko.com
联合更新语句,根据photo中的数量更新相册表Num列
原文:http://www.cnblogs.com/wurainren/p/3583894.html