
January 28th, 2013, 09:06 PM
|
 |
A Change of Season
|
|
|
|
I came up with this but I am not very happy about it:
Code:
SELECT
Q_photos.C,
`sincity_events`.`id` AS EID,
GROUP_CONCAT(sincity_events_celebrities.id) as CELEBS,
GROUP_CONCAT(sincity_celebrities.name) as CELEB_NAME
FROM (`sincity_events`)
LEFT JOIN `sincity_events_celebrities`
ON `sincity_events_celebrities`.`event_id` = `sincity_events`.`id`
LEFT JOIN `sincity_celebrities` ON `sincity_celebrities`.`id` = `sincity_events_celebrities`.`celebrity_id`
LEFT OUTER JOIN
(SELECT event_id, COUNT(1) AS C FROM sincity_event_photos GROUP BY event_id) AS Q_photos
ON Q_photos.event_id = sincity_events.id
GROUP BY `sincity_events`.`id`
ORDER BY `date` ASC
Please advise
|