检索按成员分组的每日竞赛条目
这是我的上一个问题的后续问题,我正在写这个问题会员网站的 PHP 竞赛脚本,限制每位会员每天只能参加一次。
这些条目存储在具有以下结构的“competition_entries”表中:
ce_id: primary key
ce_c_id: competition ID
ce_sub_id: member ID
ce_date: date stamp for the entry
我想编写一个 MySQL 查询来检索每个成员的条目数,
Member A: 4 entries
Member C: 2 entries
Member Y: 23 entries
etc...
但我不知道如何做到这一点。 TIA。
编辑:如果它不明显,我意识到我需要将会员 ID 关联回另一个表以检索他们的用户名 - 我可以做这一点(抱歉,漫长的一天):)
this is a followup to my previous question, whereby I'm writing a PHP competition script for a members site that restricts entries to one per day per member.
The entries are stored in a table "competition_entries" with the following structure:
ce_id: primary key
ce_c_id: competition ID
ce_sub_id: member ID
ce_date: date stamp for the entry
I would like to write a MySQL query that retrieves number of entries per member, i.e.
Member A: 4 entries
Member C: 2 entries
Member Y: 23 entries
etc...
but am struggling as to how to do so. TIA.
EDIT: In case it's not obvious, I realise I need to relate the member ID back to another table to retrieve their username - that bit I can do (sorry, long day) :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这个查询应该为您做这件事:
您应该有一个结果集,其中包含成员 ID 以及他或她所做的条目数。然后,您可以循环遍历结果,并以您描述的格式输出它们。
I think this query should do it for you:
You should have a result set with a member id and the number of entries he or she has made. You can then loop through your results, and output them in the format you described.