Reputation: 7805
for some reason (and I think I know why), when more than one row of $activityday have the same value, the other rows are no longer displayed. I think that it's because of the group by, but I can't be sure.
The $activityday is a number from 1 to 9 that represents an activity on that day. Table venues_activity takes that number and writes the name of the activity, while group by orders the activities in terms of importance.
Is there an alternative to get all of my rows shown? Thank you! :)
SELECT
venues.*,
venues_activity.ACTIVITY_EN
FROM venues
INNER JOIN venues_activity
ON $activityday = venues_activity.ID
LEFT JOIN events
ON events.VENUE_LOCATION = venues.ID
AND start_datetime >= '$DATE_START_SELECTED'
AND end_datetime < '$DATE_END_SELECTED'
where events.VENUE_LOCATION IS NULL
AND VENUE_TYPE='1'
AND $closeday!='Closed'
AND $activityday!='9'
GROUP BY $activityday
Upvotes: 1
Views: 1205
Reputation: 37388
I think you want the ORDER BY
clause... not the GROUP BY
clause.
GROUP BY
is intended to do exactly what you describe... group duplicate values into a single row, which is intended to be used in conjunction with aggregate functions, such as SUM
, AVG
, or COUNT
.
ORDER BY
simply orders the results.
Upvotes: 3