用distinct关键字去除重复记录,比如查询EMP表中JOB的种类:
MariaDB [powernode]> select distinct JOB from EMP;
注意://下面这句sql语句是错误的,distinct只能出现在所有字段的最前面
MariaDB [powernode]> select ENAME,distinct JOB from EMP;
查询DEPTNO和JOB两栏都不重复的数据:
MariaDB [powernode]> select distinct DEPTNO,JOB from EMP;
常见的案例:查询岗位的数量:
MariaDB [powernode]> select count(distinct JOB) from EMP;
来源:CSDN
作者:别断
链接:https://blog.csdn.net/Until_U/article/details/104222604