内部联接

时间:2009-04-01 11:34:37

标签: php sql mysql

$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)) {
}

所有的表和列都存在,我连接到数据库,但它仍然给了我:

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

我在这里做错了什么?

提前致谢。

1 个答案:

答案 0 :(得分:6)

您的联接语法错误。尝试:

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