gpt4 book ai didi

Mysql Distinct 返回所有重复行

转载 作者:行者123 更新时间:2023-11-29 13:30:49 25 4
gpt4 key购买 nike

我遇到了这个小问题,

当我运行这个查询时,它工作正常,但是 DISTINCT 返回所有不应该的重复值,我只是想知道为什么它会这样。

查询

SELECT DISTINCT `dstuser` , 
DATE_FORMAT( `t` , '%M %e, %Y' ) AS `date`
FROM `mail`

+---------------------+---------+---------+---------+---------+--------+
| time | srcuser | srchost | dstuser | dsthost | size |
+---------------------+---------+---------+---------+---------+--------+
| 2006-05-12 15:02:49 | phil | mars | phil | saturn | 4522 |
| 2006-05-11 10:15:08 | barb | saturn | tricia | mars | 58274 |
| 2006-05-12 12:48:13 | tricia | mars | gene | venus | 194925 |
| 2006-05-12 15:02:49 | phil | mars | phil | saturn | 1048 |
| 2006-05-12 12:48:13 | tricia | mars | link | asure | 524111 |
+---------------------+---------+---------+---------+---------+--------+

返回

+---------+--------------+
| dstuser | date |
+---------+--------------+
| tricia | May 11, 2006 |
| gene | May 12, 2006 |
| phil | May 12, 2006 |
| tricia | May 13, 2006 |
| barb | May 14, 2006 |
| tricia | May 14, 2006 |
| phil | May 14, 2006 |
| gene | May 15, 2006 |
| phil | May 15, 2006 |
| tricia | May 15, 2006 |
| barb | May 16, 2006 |
| tricia | May 17, 2006 |
| gene | May 19, 2006 |
+---------+--------------+
13 rows in set (0.00 sec)

最佳答案

DISTINCT 返回dstuserdate 的所有唯一组合。为了避免重复的用户,请尝试添加 GROUP BY dstuser

关于Mysql Distinct 返回所有重复行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19479954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com