我在某种程度上有这个查询.它返回'rating'的正确值(输出为7,最高评级),但'content'的输出来自表中的不同行.(不是最高等级的行,即7)
$bestAnswerQuery = MYSQL_QUERY("SELECT content, MAX(rating) as rating FROM answers WHERE questionID = '$questionID'");
$fetchBestAnswer = MYSQL_FETCH_ASSOC($bestAnswerQuery);
echo "$fetchBestAnswer[content] $fetchBestAnswer[rating]";
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么?我搜索过,无法找出原因不正常的原因.
I've been trying to join all the rows from two different tables. I've tried UNION and LEFT JOIN.
Right now I've just been using two separate queries and had one display after the other. I would like to merge the two queries to display at the same time.
table 1 is called 'approves' and table 2 is called 'comments'.
批准
- id
- postID
- postUserID
- userID评论
- id
- postID
- postUserID
- 用户 ID
- 评论 …