《MySQL必知必会》-第6章 过滤数据

使用select语句的where子句指定搜索条件

  • 使用where子句
select prod_name,prod_price
from products
where prod_price = 2.50;
#检索两个列,返回prod_price值为2.50的行
#where子句在from之后
#若order by和where同时使用,则order by在where之后
  • where子句操作符

mysql支持的所有条件操作符

操作符说明
=等于
<>不等于
!=不等于
<小于
<=小于等于
>大于
>=大于等于
between在指定两个值之间
#1 检测单个值
select prod_name,prod_price
from products
where prod_name = 'fuses';
#执行匹配时默认不区分大小写
select prod_name,prod_price
from products
where prod_price < 10;
#2 不匹配检查
select vend_id,prod_name
from products
where vend_id !=(<>) 1003;
#单引号用来限定字符串,与数值进行比较则不需要引号
#3 范围值检查
select prod_price,prod_name
from products
where prod_price between  5 and 10;
#包括开始值和结束值
#4 空值检查
select prod_name
from products
where prdo_price is null;
#null与字段包含0,空字符串或仅仅包含空格是不同的
select cust_id
from customers
where cust_email is null;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

_Mercurial

请我喝杯焦糖玛奇朵叭

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值