0

私はこの小さな問題に直面しています、

このクエリを実行すると正常に動作しますが、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)
4

1 に答える 1

1

DISTINCT は、dstuserANDの一意の組み合わせをすべて返しますdate。ユーザーの重複を避けるために、追加してみてくださいGROUP BY dstuser

于 2013-10-20T16:43:22.507 に答える