= 等 <>不等 >大于 <小于 >=大于等于
<=小于等于 between 小值and小值[小值,小值]
in 指定的n个固定取值 ,如in(60,90,20)
like模糊查询 通常只查字符串
% 匹配0到多个任意字符
_匹配单个任意字符
\指定转义字符 如'\_'表示普通下划线 ;'\%'表示普通百分号
is null
not :
not between and
not in
is not null
and
or
1.销售提成commission_pict不是null的员工
USE hr;
SELECT employee_id,first_name,salary,commission_pct,job_id
FROM employees
WHERE commission_pct IS NOT NULL;
2.没有上司的人
USE hr;
SELECT employee_id,first_name,salary,manager_id,job_id
FROM employees
WHERE manager_id IS NULL;
3.没有部门的人
USE hr;
SELECT employee_id,first_name,salary,department_id,job_id
FROM employees
WHERE department_id IS NULL;
4.部门80当中,薪水大于10000的员工
USE hr;
SELECT employee_id,first_name,salary,department_id
FROM employees
WHERE department_id=80 AND salary>=10000;
5.姓名中有en,且在部门50中的员工
USE hr;
SELECT employee_id,first_name,last_name,salary,department_id
FROM employees
WHERE department_id=50 AND (first_name LIKE '%en%' OR last_name LIKE '%en%');
6.部门40中所有员工,和工种后缀都是CLERK的员工
USE hr;
SELECT employee_id,first_name,last_name,salary,job_id,department_id
FROM employees
WHERE department_id=40 OR job_ID LIKE '%CLERK';