PDA

View Full Version : Viewing all posts (not topics) in a forum.


Axe
01-11-2003, 11:52 PM
Hey there,

Now, I know I can do...

mysql> select threadid, title, dateline from thread where forumid="40";

To view all the threads in a particular forum.

But, how can I request all POSTS (threadid, postid, username, userid title, dateline) in those threads in a single MySQL query?

Further to this, how can I do the above request but limit it to THREADS that started (and not when the last post was made to those threads) within the last XX days?

Thanks :)

Axe
01-12-2003, 02:17 AM
Okies, I figured out the first bit...

select post.threadid, post.postid, post.title, post.dateline as postdate, thread.dateline as threaddate from post, thread where post.threadid=thread.threadid && thread.forumid="40" order by threaddate desc, postdate asc;

Which gives me all the posts in a particular forum area.

The results are first sorted by the date of the thread (most recent first), then by the date of the posts (oldest first).

Now, how can I limit this to threads that were started within the last 30 days? (bear in mind, that there could be a post in the last 30 days which is on a 2 year old thread, and I don't want that to show).