把查询结果去除重复记录 distinct
    注意:原表数据不会被修改,只是查询结果去重。

    1. // distinct只能出现在所有字段的最前方。
    2. mysql> select distinct job from emp;
    3. // distinct出现在job,deptno两个字段之前,表示两个字段联合起来去重。(两个字段合起来看是否有一样的,然后去除)
    4. mysql> select distinct job,deptno from emp;
    5. 统计工作岗位的数量
    6. 1.去重 2.分组函数统计数量
    7. select count(distinct job) from emp;
    8. +---------------------+
    9. | count(distinct job) |
    10. +---------------------+
    11. | 5 |
    12. +---------------------+

    [

    ](https://blog.csdn.net/weixin_43896929/article/details/120750965)