【发布时间】:2015-08-16 07:33:41
【问题描述】:
我正在尝试将我的 users 表添加到我现有的查询中,以便我可以将 users.id 与 forum_topics.topic_creator 进行匹配,这样我就可以将它们匹配并允许自己将其分配给该用户的用户名。
这是我的原始查询。
$query2 = mysqli_query($con,"SELECT t.*, COUNT(p.topic_id)
AS tid2 FROM forum_topics AS t JOIN forum_posts
AS p on t.id = p.topic_id WHERE t.category_id = ".$cid."
GROUP BY t.id DESC")
然后我尝试这样做..
$query2 =mysqli_query($con,"SELECT t.*, COUNT(p.topic_id)
AS tid2 FROM forum_topics AS t JOIN forum_posts
AS p on t.id = p.topic_id WHERE t.category_id = ".$cid."
INNER JOIN users AS u
ON t.topic_creator = u.id
GROUP BY t.id DESC")
or die ("Query2 failed: %s\n".($query2->error));
我收到失败消息。
我做错了什么?
【问题讨论】: