It's not very apparent in forums like this one on phpbuilder because all the replies are just printed in the order they cam in (which is shite because you can't tell who's replying to who), but posts are always replies to other posts, so every post should have a 'replyto' or 'parent' field indicating which post this is a reply to.
The first post in a thread simply has a NULL value for the parent, because it does not have a parent.
Then you can select the threads using
SELECT threadid FROM table WHERE parentid IS NULL;
Technically you can trace the entire thread from this first post due to the parent/child relations, but this is a complex and slow operation.
It is therefore better to also store the thread-id in every reply, so you can limit your search to records that have the same thread-id.