DQL语言的查询

进阶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,而不是=

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值