MYSQL--where语句

where子句的操作符如下

1.检查单个值

语句:select * from products where vend_id = 1002;

截图:

2.检查多个值

语句:select * from products where vend_id = 1002 and prod_price = 3.42;

截图:

解释:多个值之间用and, or 连接。

3.不匹配检查

语句:select * from products where vend_id != 1002 order by vend_id;

截图:

解释:在同时使用order by和where子句时,应该让order by位于where之后。

4.范围值检查

语句:select * from products where prod_price between 5 and 10 order by prod_price;

截图:

解释:查找范围时,用between and连接两个值。

5.空值检查

语句:select * from products where prod_price is null;

截图:

解释:价格为空是指没有价格,不是指价格为0.

6.in语句

语句:select * from products where vend_id in(1002, 1003);

截图:

解释:

in 和 or的效果一样

它们的区别是:
1.in操作符的语法更清晰更直观
2.在使用in操作符是,计算的次序更容易管理。
3.in操作符一般比or操作符执行更快。
4.in可以包含其他select语句,使得更动态地建立where子

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值