PDA

View Full Version : sql problem (sorta! :))


merk
10-03-2002, 12:45 PM
SELECT MAX(thread.title) as ttitle,MAX(thread.dateline) as dateline,MAX(thread.threadid) as threadid,MAX(thread.replycount) as comments,MAX(thread.lastpost) as lastpost,forum.forumid,forum.title,forum.descripti on,forum.parentid FROM thread
INNER JOIN forum USING (forumid)
GROUP BY forum.forumid
HAVING forum.parentid=8
ORDER BY dateline DESC


This returns the correct result the first time (the forum that was updated the latest), with the correct name of the latest thread.

But all subsequent forums that it returns(still in the correct order of latest "thread"), it returns the first thread of that forum, not the latest.

I can do it with a sub-select, but mysql doesnt support that. Any thoughts?

merk
10-03-2002, 10:43 PM
Okay, looking through my code, i see my max() is wrong.

Max returns the thread title that has the "highest" name, ie, starts with a W/X/Y/Z..

Which is _not_ what i want :)

I had it working before, but there was a SQL query per entry, which added around 24 queries per page, which i dont want to do :(

Any ideas? :D