<>1, Remove duplicate records from query results 【distinct】
be careful : The original table data will not be modified , Only the query results are de duplicated . A keyword is required for de duplication :distinct mysql> select distinct job from
emp; +-----------+ | job | +-----------+ | CLERK | | SALESMAN | | MANAGER | |
ANALYST | | PRESIDENT | +-----------+ // This writing is wrong , syntax error . //
distinct Can only appear in the front of all fields . mysql> select ename,distinct job from emp; //
distinct Appear in job,deptno Before two fields , Indicates that the two fields are combined to remove duplicates . mysql> select distinct job,deptno
from emp; +-----------+--------+ | job | deptno | +-----------+--------+ |
CLERK | 20 | | SALESMAN | 30 | | MANAGER | 20 | | MANAGER | 30 | | MANAGER | 10
| | ANALYST | 20 | | PRESIDENT | 10 | | CLERK | 30 | | CLERK | 10 |
+-----------+--------+ Count the number of jobs ? select count(distinct job) from emp;
+---------------------+ | count(distinct job) | +---------------------+ | 5 |
+---------------------+

Technology