select distinct a
from ...
-- 查询字段a 并去除重复数据
select distinct a,b
from ...
-- ab组合 去除重复数据
1.部门编号
USE hr;
SELECT DISTINCT department_id
FROM employees
WHERE department_id IS NOT NULL;
2.工种代码
USE hr;
SELECT DISTINCT job_id
FROM employees ORDER BY job_id;
3.主管id
USE hr;
SELECT DISTINCT manager_id
FROM employees
WHERE manager_id IS NOT NULL;
4.部门中的主管id
USE hr;
SELECT DISTINCT department_id,manager_id
FROM employees
WHERE department_id IS NOT NULL
AND manager_id IS NOT NULL
ORDER BY department_id,manager_id;
网友评论