我知道还有其他类似的帖子,我一直在使用它们。我有三张桌子:
users_info
user_id | user_name
blog_comments
comment_id | comment
blog_reply
user_id | comment_id | reply | reply_date
我正在尝试加入表格以从 users_info 获取 user_name 并通过 blog_comments.comment_id 返回 blog_reply
我一直在使用: 评论和评论回复的mysql结构
我被困在表连接上,非常感谢任何帮助。
$get_replies = ("SELECT
blog_reply.user_id,
blog_reply.comment_id,
blog_reply.reply,
blog_reply.reply_date,
users_info.user_name AS user_name
FROM blog_reply
JOIN users_info ON blog_reply.user_id = users_info.user_id
LEFT JOIN blog_comments ON blog_reply.comment_id = blog_reply.comment_id
JOIN users_info ON blog_reply.user_id = users_info.user_id
WHERE blog_comments.comment_id = '{$comment_id}'
ORDER BY blog_reply.reply_date DESC");
$reply = mysql_query($get_replies);