0

我有 3 张桌子

  • 用户
  • 话题
  • 帖子

我已经成功地能够加入主题和用户以显示相关信息,但现在我也试图从中获取“post_content”,posts但没有运气。

这是我的代码。

$sql = "SELECT users.user_id, users.username, users.profile, topics.topic_id,
           topics.category, topics.sub_category, topics.topic_data, 
           topics.posted_by, topics.posted, topics.view, topics.reply, posts.post_content 
    FROM topics
    LEFT JOIN users
    ON topics.posted_by = users.user_id
    WHERE topics.category = '" . mysql_real_escape_string($_GET['category']) . "' 
    AND topics.sub_category = '" . mysql_real_escape_string($_GET['sub_category']) . "' 
     OR topics.category = '" . mysql_real_escape_string($_GET['category']) . "' 
     OR topics.sub_category = '" . mysql_real_escape_string($_GET['sub_category']) . "' ORDER BY topics.posted DESC";

我查看了公会以及如何加入 JOINS,但对此感到困惑。

4

0 回答 0