Log in

View Full Version : (SQL) Recursive forum order by?


ThorstenA
08-14-2008, 05:15 PM
I want to select the closest to actual forum announcement.
Only if then in this forum is more than 1 announcement, it should take newest one.

Example:
Announcement 1 (08/2008) grandparentforum > parentforum > Announcement 2 (07/2008) (actual) childforum

When I am browsing in childforum, I want to be presented with announcement 2.
Currently there's only the newest announcement 1 presented, even if the second announcement is "closer" to actual childforum.


SELECT *
FROM " . TABLE_PREFIX . "announcement AS announcement
WHERE " . fetch_forum_clause_sql($foruminfo['forumid'], 'forumid') . "
ORDER BY startdate DESC, announcementid DESC


fetch_forum_clause_sql gives back a $parentlist.

So how should I rewrite this query to select announcement from closest forum from parentlist instead of newest announcement? Thanks very much.

--------------- Added 1218798679 at 1218798679 ---------------

I decided to not use this feature in my cms (https://vborg.vbsupport.ru/showthread.php?t=188087). So I do not need to know an answer, but I am curious how to achieve that :)