Steve,

Looks like your missing your FROM portion of your query.  That's pretty
important.

Also, how do you know when a post is new?  Are you just assuming that if the
database returns it with your LIMIT condition that it comes off the top of
the list and is new?  I don't think that's too reliable.  You should add a
timestamp field to the post table so you can tell which posts are the
newest.  You could then do something like this:

SELECT topics.topic_title FROM topics WHERE topics.topic_id IN (
    SELECT DISTINCT posts.topic_id FROM posts ORDER BY posts.date LIMIT 10);

Something like that would work.

Good Luck,
Jason Cox

> I'll give you all the short version of what I need and if it is enough for
> you to help that would be great. I need to pull the last 10 updated topics
> from a table and output them. However, the posts table lists each post and
> then has a topic id. There is also a table of topics with topic id, title,
> etc. I cannot just pull the last 10 posts in the post table because those
> posts could all be for the same topic and I'm trying to output the last 10
> updated topics (not posts). How can I do this? I can't find anything on
the
> subject. This is what I tried as a random guess:
> $sql = "SELECT DISTINCT posts.topic_id, posts.forum_id,
topics.topic_title,
> topics.topic_replies WHERE topics.topic_id = posts.topic_id DESC LIMIT
10";



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to