进阶2
分类:
一、按条件表达式筛选
条件运算符:> 、< 、= 、!=(<>) 、>= 、<=
二、 按逻辑表达式筛选
逻辑运算符: &&(and)、 ||(or)、 !(not)
三、 模糊查询
like、between and、in、is null或is not null
语法:
select 查询列表 3
from 表名 1
where 条件 2
一、按条件表达式筛选
eg 1、查询工资大于10000的员工信息
select * from employees where salary > 10000;
eg 2、查询工资在一万到两万之间的员工信息
select * from employees where salary >= 10000 and salary <= 20000;
三、模糊查询
1、like
eg 1、查询员工名中包含字符a的员工信息
select * from employees
where last_name like '%a%';
说明:
like一般要和通配符使用
通配符 %:零个或任意多个字符
_ :一个字符
2、betwee and
eg 1、查询员工编号在100~120的员工信息
select *
from employees
where employee_id between 100 and 120;
3、in
eg 1、查询员工工种编号是IT_PROG 、AD_VP 中的一个员工名和工种编号
select last_name,job_id
from emloyees
where job_id in ('IT_PROG','AD_VP');
4、is null
eg 1、查询没有奖金的员工名和奖金率
select last_name,comimission_pct
from employees
where comimission_pct is null;
注意要判断是否为空必须用is,而不是=