I have a table of Calendar event information (Date, username).
I want to print the following information for each "event" for a selected month in a table, using PHP and MySQL:
SELECT DAYOFWEEK( eventDate ) AS
DAY , YEAR( eventDate ) AS YEAR, `primary` , secondary, weekend
FROM eventcal
WHERE region = 4
AND MONTH( eventDate ) =7
ORDER BY DAYOFWEEK( eventDate )
There can be multiple users associated with a given day. What's the best way to, using MySQL and PHP, build the table so that the usernames sharing a common day are merged together? For example, instead of:
June | 7 | 2009 | doej2
June | 7 | 2009 | smithj2
June | 8 | 2009 | mccoyj2
I want...
June | 7 | 2009 | doej2, smithj2
June | 8 | 2009 | mccoyj2
Any ideas?
Same question as: Grouping in SQL
Suggested was to use MySQL's GROUP_CONCAT
GROUP_CONCAT is your keyword. Example : http://www.mysqlperformanceblog.com/2006/09/04/group_concat-useful-group-by-extension/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.