distinct is based on all selected columns

select name, day from my_table;
+——————+—————+
| name       | day                |
+——————+—————+
| ABC       | 2011-11-13    |
| ABC       | 2011-11-13    |
| ABC       | 2011-11-14    |
| ABC       | 2011-11-14    |
| SURE    | 2011-11-15    |
| SURE    | 2011-11-15    |
| SURE    | 2011-11-16    |
| SURE    | 2011-11-16    |
+——————+—————+
10 rows in set (0.08 sec)

mysql> select distinct name, day from my_table;
+——————+—————+
| name             | day              |
+——————+—————+
| ABC   | 2011-11-13    |
| ABC   | 2011-11-14    |
| SURE | 2011-11-15    |
| SURE | 2011-11-16    |
+——————+—————+

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s