小编Ian*_*inn的帖子

为什么sql MAX功能不正常?

我在某种程度上有这个查询.它返回'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)

谁能告诉我为什么?我搜索过,无法找出原因不正常的原因.

php sql max

2
推荐指数
1
解决办法
4933
查看次数

Join all rows from two different tables MySQL

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
- 评论 …

mysql union join

0
推荐指数
1
解决办法
8617
查看次数

标签 统计

join ×1

max ×1

mysql ×1

php ×1

sql ×1

union ×1