Help w/ phpBB Query
I am trying to list the last X unique topics.
Here are the tables/columns in question:
Basically, I need to grab the last X unique
topic_id values based on their post_time.
But, I need to pull the topic_title from the
other table where both topic_ids are equal.
Any help here? :)
PS- I am not going to use any "MOD" utils.
I want to do this with straight, simple SQL.
(Keeps my upgrade paths simpler/easier.)
I am kinda confused as to exactly what you want. You want to select certian posts_t.topic_id based on posts_t.post_time and then select the topics_t.topic_title that matches tposts_t.topic_id==topics_t.topic_id?
Also what db server do you have?
I am running phpBB with MySQL on the backend.
I want the posts_t.topic_id based on posts_t.post_time
(but only unique topic_id values). And then I need to
pull the topics_t.topic_title for each of the topic_id #s.
Using SELECT DISTINCT posts_t.topic_id, posts_t.post_time
it gets the latest topic_ids, but they are not "unique" since it
uses the entire row (and each post_time is unique).
So what you're trying to do is to see which topics have been posted to lately, right?
Now, it has been several months since I did anything SQL (or database, at all) related, but shouldn't you do something like this?
I had to remember SQL while writing this, so it is by no means correct syntax. I just think it's the basic thing to do.
SELECT TOP 10 topics_t.topic_id, topics_t.topic_title, MAX(posts_t.post_time) AS post_time FROM posts_t RIGHT JOIN topics_t ON (posts_t.topic_id = topics_t.topic_id) GROUP BY topics_t.topic_id, topics_t.topic_title ORDER BY post_time DESC;