【SQL语句】SQL select distinct语句

在表中,一个列可能会包含多个重复值,有时您也许希望仅仅列出不同(distinct)的值。

语法:SELECT DISTINCT column_name,column_name
 FROM table_name;举例:以下是websites表格

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/    | 1     | USA     |
| 2  | 淘宝          | https://www.taobao.com/   | 13    | CN      |
| 3  | 菜鸟教程      | http://www.runoob.com/    | 4689  | CN      |
| 4  | 微博          | http://weibo.com/         | 20    | CN      |
| 5  | Facebook     | https://www.facebook.com/ | 3     | USA     |
+----+--------------+---------------------------+-------+---------+
select distinct country from websites;
posted @ 2018-06-20 08:41  foreverlove~  阅读(214)  评论(0编辑  收藏  举报