I've written a query to perform a search. One of the options is to filter by bookings_history, which I've emboldened below.
Any given booking can have one or more booking history items, so each booking has at least one booking history item.
The intention of this option is that when a booking history label type is selected, only bookings with those booking history items associated with them are to be included in the results.
However, rather than exclude from the results, it's kind of including them via the counter query I'm using. I suspect a subquery or GROUP BY on the counter query may be in order, but I just can't figure this one out, I'm afraid.
The following is the two queries...
COUNT(bookings.booking_id) AS count
DATE_FORMAT(bookings.creation_date, '%a %D %b %y'),
DATE_FORMAT(bookings.modification_date, '%a %D %b %y'),
DATE_FORMAT(bookings_attendees.stay_date, '%a %D %b %y'),
venues.name AS venue,
venues.town_city AS venue_town_city
And they both share the following...
ON (bookings.booking_id = bookings_attendees.booking_id)
AND (bookings.client_id = '3')
ON (bookings.booking_id = bookings_clients.booking_id)
ON (clients.client_id = bookings_clients.client_id)
AND (clients.client_id = '1')
ON (venues.venue_id = bookings.venue_id)
AND (bookings_attendees.name LIKE ('%John%'))
AND (venues.venue_id = '74')
AND (bookings.status = 'confirmed')
[B] INNER JOIN[/B]
[B] ON (bookings_history.label = '1')[/B]
[B] AND (bookings_history.booking_id = bookings.booking_id)[/B]
[B] AND (bookings_history.client_id = bookings.client_id)[/B]
[B] AND (bookings.client_id = '3')[/B]
GROUP BY bookings.booking_id
first of all, your GROUP BY is seriously wrong
beyond that, i can't think
please see http://dev.mysql.com/doc/refman/5.0/en/group-by-hidden-columns.html
Yeah, I've been trying lots of things and the GROUP BY found its way through, but that only applied to the actual search query and not the count query.
This topic is now archived. It is frozen and cannot be changed in any way.