PDA

View Full Version : Getting first post in thread


tlaplugins
10-15-2010, 01:38 PM
I have been having trouble getting the first post in a thread depending on the vbulletin implementation

here is the sql im using

SELECT post.title, thread.title AS ttitle, post.threadid, post.pagetext, post.dateline, thread.forumid, post.postid, postparsed.pagetext_html
FROM ".TABLE_PREFIX."post as post
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON thread.threadid = post.threadid
LEFT JOIN " . TABLE_PREFIX . "postparsed AS postparsed ON postparsed.postid = post.postid
WHERE
post.visible != 2 AND parentid=0
GROUP BY
post.postid
ORDER BY
post.postid ASC

does anyone have a better more general way of getting the first post in every thread that is published?

Lynne
10-15-2010, 01:42 PM
Why do you have the Group By line in there?

tlaplugins
10-15-2010, 02:09 PM
I just add it to ensure we only get one postid and no duplicates for that postid in case of some custom coding