title: SQL multiple joins SELECT query
body: <p>I've build the following query</p>
  
  <pre><code>$subforumsquery = "
          SELECT
            forums.*,
            posts.title   AS lastmsgtitle,
            posts.timee   AS lastmsgtime,
            posts.useraid AS lastmsguseraid,
            posts.useradn AS lastmsguseradn,
            users.photo   AS lastmsgphoto
          FROM forums
            LEFT JOIN posts
              ON (posts.forumid = forums.id)
            LEFT JOIN users
              ON (posts.useraid = users.id)
          WHERE forums.relatedto = '$forumid'
              and posts.type = 'post'
          ORDER BY `id` DESC";
  </code></pre>
  
  <p>I don't know why, but i get the same subforum twice even that there is only 1 sub forum.</p>
  
  <p>BTW, is there any way to select only the last post insted of searching all?</p>
  
  <p>Thanks!</p>