6.between...and...

6.在WHERE中使用between...and...
  用于区间值的条件判断(包含边界值)
 
  //查询工资在2000(包含)到3000(包含)之间的员工信息
  select empno,ename,sal
  from emp
  where sal>=2000 and sal<=3000;
  //采用between...and...实现
  select empno,ename,sal
  from emp
  where sal between 2000 and 3000;
 
  //查询2081年入职的,工资在2000和3000之间(包含)
  //的员工信息
  select empno,ename,sal
  from emp
  where to_char(hiredate,'yyyy')='2081'
    and sal between 2000 and 3000;
 
  //查询2081到2083年之间入职的员工信息
  select empno,ename,sal
  from emp
  where to_char(hiredate,'yyyy')>='2081'
    and to_char(hiredate,'yyyy')<='2083'
posted @ 2016-05-16 11:28  YunMan  阅读(184)  评论(0编辑  收藏  举报