Posts: 1,832
Location: Somewhere else entirely
|
I think it is caused by the GROUP BY section - group by is for summarising groups of things, which means you give a column to group by (medno_id), and then a way to combine the other columns, such as MAX(med_effdate). Here MAX is an aggregate function since it is 'aggregating' the dates into one value - the maximum. Because class_id and unit_id etc appear on their own, the database doesn't know how to combine the values (even though they are all probably the same).
I suggest this - select all the columns as normal without the MAX(), that will get you all the records with the right medno_id. Then use ORDER BY med_effdate DESC to sort by date, and put the most recent one at the top. Then you can use LIMIT 1 to only take the first result. This should get you the right result without the errors.
So in full:
Code:
SELECT tblMedia.medno_id, tblMedia.med_effdate, tblMedia.class_id, tblMedia.unit_id, tblmedia.med_title
FROM tblMedia
WHERE tblMedia.medno_id = 50
ORDER by tblMedia.med_effdate DESC
LIMIT 1
Without knowing the exact database system you are using, I can't be sure of the syntax, but something close to this should work.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';
Please login or register to view this content. Registration is FREE (aka MSN handwriting for forums)
|