把查询结果去除重复记录 distinct
注意:原表数据不会被修改,只是查询结果去重。
// distinct只能出现在所有字段的最前方。mysql> select distinct job from emp;// distinct出现在job,deptno两个字段之前,表示两个字段联合起来去重。(两个字段合起来看是否有一样的,然后去除)mysql> select distinct job,deptno from emp;统计工作岗位的数量1.去重 2.分组函数统计数量select count(distinct job) from emp;+---------------------+| count(distinct job) |+---------------------+| 5 |+---------------------+
[
](https://blog.csdn.net/weixin_43896929/article/details/120750965)
