更新歌手MV歌曲数和歌手总人气
declare @gsid int
declare @songnum int
declare @songnum int
declare @songallhit int
declare rq cursor for select distinct gsid from MV歌曲表 where sh=1 and isok=0 order by gsid asc
open rq
fetch next from rq into @gsid
declare rq cursor for select distinct gsid from MV歌曲表 where sh=1 and isok=0 order by gsid asc
open rq
fetch next from rq into @gsid
while @@FETCH_STATUS = 0
begin
select @songnum =count(id),@songallhit=sum(allhit) from MV歌曲表 where gsid=@gsid and sh=1 and isok=0
update 歌手表 set mvnum=@songnum,mvrq=@songallhit where gsid= @gsid
fetch next from rq into @gsid
end
close rq
deallocate rq
begin
select @songnum =count(id),@songallhit=sum(allhit) from MV歌曲表 where gsid=@gsid and sh=1 and isok=0
update 歌手表 set mvnum=@songnum,mvrq=@songallhit where gsid= @gsid
fetch next from rq into @gsid
end
close rq
deallocate rq