如何/可以合并这两个查询? 现在我在查询中运行一个查询来检查观看评论的人是否已经喜欢评论
第二个查询检查用户是否喜欢该特定评论
查询
$stmt = $dbCon->prepare("SELECT t1.login_comments_id, t1.login_comments_comment, t2.login_users_profile_image "
. " FROM login_comments t1 "
. " INNER JOIN login_users t2 "
. " ON t1.login_comments_commenter_fk = t2.login_users_id "
. " WHERE t1.login_comments_comment_profile_fk = ? "
. " ORDER BY t1.login_comments_id "
. " DESC ");
$stmt->bind_param('i', $profileId);
$stmt->execute();
$stmt->bind_result($commentsId, $commentsComment, $commentsProfilePicture);
while ($stmt->fetch()) {
$stmt = $dbCon->prepare("SELECT login_likes_status "
. " FROM login_likes "
. " WHERE login_likes_user_id = ? "
. " AND login_likes_comments_id = ? "
. " AND login_likes_status = 1 ");
$stmt->bind_param('ii', $profileId, $commentsId);
$stmt->execute();
$stmt->bind_result($status);
$stmt->fetch();
echo $status;
}
有可能吗?或任何其他建议/解决方案?