I have a rather complicated query that captures data from three tables, and now I want it to be even more complicated (Oh dear)!
I would like the last published function to appear in its own section of the page, and it's pretty easy by selecting the last entry in the table. However, for a complex request (the main page of the site) I would like to be able to NOT show this function.
I would like union to execute the following query against my previous query, but it does not return the correct results:
SELECT features.featureTitle AS title, features.featureSummary AS body, features.postedOn AS dummy, DATE_FORMAT( features.postedOn, '%M %d, %Y' ) AS posted, NULL, NULL, staff.staffName, features.featureID FROM features LEFT JOIN staff ON features.staffID = staff.staffID WHERE features.postedOn != MAX(features.postedOn) ORDER BY dummy DESC LIMIT 0,15
This query returns the following error:
MySQL Error: # 1111 - Invalid use of group function
Is there any way around this?
source share