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) 🙂
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.