Sunday, April 17, 2011

Inner Join

$query4 = mysql_query("SELECT * FROM comments WHERE content_id = '$id' AND     content = 'thread'
                  INNER JOIN users ON comments.poster = users.id
               ORDER BY comments.date ASC");
while ($comment = mysql_fetch_array($query4)) {
}

all the tables and columns exist and i am connected to the database but it still gives me:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in thread.php on line 63

What am i doing wrong here?

Thanks in advance.

From stackoverflow
  • Your join syntax is wrong. Try:

    SELECT *
    FROM comments
    INNER JOIN users ON comments.pooster = users.id
    WHERE comments.content_id = '$id'
    ORDER BY comments.date ASC
    

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.