BEGIN
# 统计视频使用的模板数
UPDATE VideoTemplate vt
INNER JOIN (
SELECT
TemplateId,
COUNT(TemplateId) AS TotalCount
FROM
VideoWorks
WHERE
Type = 1
GROUP BY
TemplateId
) work_total_count
ON vt.Id = work_total_count.TemplateId
SET vt.RenderTotalCount = work_total_count.TotalCount;
END
-----------------------------------------------------------------------------------------------------------
BEGIN
# 统计合成使用的背景音,主播,文本范例的数量
UPDATE VideoBgm vb
INNER JOIN (
SELECT
BgmId,
COUNT(BgmId) AS TotalCount
FROM
VideoWorks
WHERE
Type = 1
GROUP BY
BgmId
) work_total_count
ON vb.Id = work_total_count.BgmId
SET vb.UseCount = work_total_count.TotalCount;
UPDATE VideoTextExample vte
INNER JOIN (
SELECT
TextExampleId,
COUNT(TextExampleId) AS TotalCount
FROM
VideoWorks
WHERE
Type = 1
GROUP BY
TextExampleId
) work_total_count
ON vte.Id = work_total_count.TextExampleId
SET vte.UseCount = work_total_count.TotalCount;
UPDATE ChannelAndSpeaker s
INNER JOIN (
SELECT
SpeakerId,
COUNT(SpeakerId) AS TotalCount
FROM
VideoWorks
WHERE
Type = 1
GROUP BY
SpeakerId
) work_total_count
ON s.No = work_total_count.SpeakerId
SET s.UseCount = work_total_count.TotalCount;
END