我是 mysql 新手,从 mysql 数据库中选择数据时遇到问题:
$post_id = 3;
$current_user_id = 1;
$query = "SELECT `comments`.*, `users`.`username`, `users`.`image` FROM (`comments`)
LEFT JOIN `users` ON `comments`.`user_id` = `users`.`id`
WHERE `comments`.`post_id` = '$post_id'
AND `comments`.`status` = 1
AND `users`.`status` = 1
ORDER BY `comments`.`date` desc";
此选择,从数据库中选择所有已批准的评论,而且,在此选择中,我需要 $current_user_id 的所有未批准评论,
结果必须如下所示:
[所有已批准的帖子评论] + [$current_user_id 的所有未批准的帖子评论]