数据库Oracle的select用法(部分)

Oracle的select用法(部分):

1.查询所有:

select * from employees;

 

2.加上where子句:用选择限制行

select * from employees where  SALARY<8000;

查询 employees中salary小于8000的所有人信息:

 

3.Where子句_IS NULL和is not null

select employee_id,last_name from employees where COMMISSION_PCT is null; 

查询employees表中COMMISSION_PCT为null的员工编号,姓名。

select employee_id,last_name,COMMISSION_PCT from employees where COMMISSION_PCT is not null;

查询employees表中COMMISSION_PCT不为null的员工编号,姓名,以及COMMISSION_PCT。

4.between and语句

select last_name,employee_id,salary from employees where salary between 8000 and 10000 order by salary;

 

5.where子句的模糊查询(关键字 like        % _,%号表示,有0-多个字符):

select last_name from employees where last_name like '%a%';

查询名字中含有a的用户所有名字。

 

6.escape  转义字符:

select  JOB_ID from employees where  JOB_ID like 'SH\_%' escape '\';

查询带有SH_ 字符的职业id。

7 .优先规则

 查询工作岗位是 SA_REP 或者工作岗位是 AD_PRES 并且薪水大于 15000 的员工姓名、
工作 ID 以及薪水。

select last_name,job_id,salary from employees where job_id='SA_REP' or job_id='AD_PRES' and salary>15000;

 

查询工作岗位是 SA_REP 或者是 AD_PRES 并且他们的薪水大于 15000 的员工姓名、工
作 ID 以及薪水。

select last_name,job_id,salary from employees where (job_id='SA_REP' or job_id='AD_PRES') and salary>15000;

 

 

 

 

 

 

 

 

posted @ 2019-12-11 08:56  sakura-yxf  阅读(629)  评论(0)    收藏  举报