View Single Post
Old 01-16-2005, 04:14 PM   #6 (permalink)
welshbyte
Insane
 
Location: Wales, UK, Europe, Earth, Milky Way, Universe
Solved!! EDIT: NOT!

Well i originally posted a big thank you here but the SQL query i came up with just seemed to work because the last 5 posts in my forum were all from different topics. Here's what i'm dealing with now:
Code:
SELECT
    p.post_id, p.post_topic, max( p.post_time ) AS PTIME,
    u.user_name, u.user_id,
    t.topic_title, t.topic_id, t.topic_replies, t.topic_views,
    f.forum_name, f.forum_id
FROM
    wb_posts p
LEFT JOIN
    wb_topics t ON p.post_topic = t.topic_id
LEFT JOIN
    wb_forums f ON t.topic_forum = f.forum_id
LEFT JOIN
    wb_users u ON p.post_author = u.user_id
GROUP BY
    p.post_topic
ORDER BY
    PTIME DESC
LIMIT
    0 , 5
I find that part of this query works in getting the last 5 topics correctly but if , say, the original poster was also the last poster, it would select the original post of the topic.

Its getting quite frustrating and i think i may have to use two queries and a bit of php to kludge them together which i'm not too keen on.

Oh, and that "top 5" statement doesnt work with this mysql server either
__________________
There are only two industries that refer to their customers as "users". - Edward Tufte

Last edited by welshbyte; 01-16-2005 at 06:02 PM.. Reason: Totally wrong
welshbyte is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76