一.sql-select

**演示表**

+----+--------------+---------------------------+-------+---------+

| 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    |

+----+--------------+---------------------------+-------+---------+

**实例:**

1.SELECT name,country FROM Websites;

2.SELECT * FROM Websites;

3.**SELECT DISTINCT 语句**:在表中,一个列可能会包含多个重复值,有时您也许希望仅仅列出不同(distinct)的值。DISTINCT 关键词用于返回唯一不同的值。

**演示表**

+----+--------------+---------------------------+-------+---------+

| 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;

**执行结果:**

你可能感兴趣的:(一.sql-select)