Welcome Guest, Not a member yet? Register   Sign In
MySQL: Get last forum post date
#3

[eluser]codex[/eluser]
Actually, the second approach is not bad at all. Now why didn't I think of that Wink

Thanks!

[quote author="mironcho" date="1201667182"]One approach is to use such sub select (sorry - query is not translated to CI AR)
Code:
SELECT
    f.*,
    (SELECT post_date FROM forum_posts WHERE post_id = f.post_id OR post_parent_id = f.post_id ORDER BY post_date DESC LIMIT 1) AS last_post_date
FROM
    forum_posts AS f
WHERE
    post_parent_id = '0'
    AND post_cat_id = $category_id
ORDER BY
    last_post_date DESC

Other, faster, solution is to use additional field in your table - last_post_date. Just update it in "master post" whenever there is a change in it's thread.

Hope this helps.
Miro[/quote]


Messages In This Thread
MySQL: Get last forum post date - by El Forum - 01-29-2008, 02:03 PM
MySQL: Get last forum post date - by El Forum - 01-29-2008, 04:26 PM
MySQL: Get last forum post date - by El Forum - 01-29-2008, 04:35 PM
MySQL: Get last forum post date - by El Forum - 01-29-2008, 06:12 PM



Theme © iAndrew 2016 - Forum software by © MyBB