Results 1 to 2 of 2

Thread: Need some direction...

  1. #1
    Join Date
    Apr 2003
    Location
    Shangrilah
    Posts
    1

    Need some direction...

    I am having trouble understanding this SQL statement. Can someone shed some light on the subject for me? I wish to modify the statement to extract more data than it does... What i would like to do is either simplify/reformat the statement or understand what all the u.user and ". USERS_TABLE stuff is all about... please help me

    Code:
    SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
            FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
            LEFT JOIN " . FORUMS_TABLE . " f ON t.forum_id=f.forum_id 
            WHERE t.topic_poster = u.user_id AND p.post_id = t.topic_first_post_id AND p2.post_id = t.topic_last_post_id AND u2.user_id = p2.poster_id
            ORDER BY t.topic_last_post_id DESC 
            LIMIT $limit

  2. #2
    Join Date
    Nov 2002
    Location
    DE
    Posts
    246
    The query looks in the posts table and lists the first and the last post for each topic together with the details of the users who have posted them.

    Looks like it does something similar as the list page in this forum: It shows all the topics in each forum with the thread starter, last poster, last posting date.

    I am not very familiar with MYSQL but I think it limits the resultset to $LIMIT records.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •