使用另一个 MySQL 表的 COUNT 更新
我正在尝试使用另一个表 Videos
中的 COUNT 来更新表 Profiles
中的列。所有视频都存储在 Videos
表中,我想在 Profiles
中创建一个名为 VideoCount
的列,其中显示该用户视频的 COUNT 个Videos
表。
基本上,我想运行一个 cron 作业 - 所以我需要知道如何在 Videos
表中查找用户视频的计数,然后在 VideoCount
中更新该用户的 VideoCount
code>Profiles 包含此计数。
要识别谁上传了哪个视频,Videos
.Owner
和 Profiles
.ID
应匹配。有人知道我需要为 PHP 文件 cron 作业运行的 SQL 吗?
I'm trying to update a column in table Profiles
with a COUNT from another table Videos
. All videos are stored in the Videos
table, and I want to create a column in Profiles
called VideoCount
which shows the COUNT of that user's videos in the Videos
table.
Basically, I want to run a cron job - so I need to know how to find the COUNT of a user's videos in the Videos
table and then UPDATE that user's VideoCount
in Profiles
with this count number.
To identify who's uploaded which video, Videos
.Owner
and Profiles
.ID
should be made to match. Does anybody know the SQL which I need to run for the PHP file cron job?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尽可能简单^^
,如果您想要它奇特:您可能需要的所有触发器:
as simple as it can be^^
and if you want it fancy: all the triggers you might need:
如果您想更新视频计数,您可以在上传时更新视频计数,因此我认为不需要 cron 作业。
If you want to update video count that you can upadate video count at the time of upload, so as i think there is no need for the cron job for this.
就像
我不确定这个语法是否完全正确。尝试一下
Something like
I'm not sure this syntax is completely correct. give it a try