SQL(5)- 高级数据过滤

where + and or in not

  1. select prod_name,prod_price from product where vend_id = ‘dell01’ and prod_price<5000;
  2. select prod_name,prod_price from product where vend_id = ‘DEL01’ or vend_id = ‘HUA01’;
  3. select prod_name,prod_price from product where (vend_id = ‘DEL01’ or vend_id = ‘HUA01’ ) and prod_price<5000; and 的优先级高于or,如果不加括号,则会筛选出价格小于5000的品牌名称为HUA01的产品及全部品牌名为DEL01的产品。加括号后筛选结果为HUA01及DEL01两个品牌价格小于5000产品。
  4. select prod_name,prod_price from product where vend_id in ( ‘DEL01’ ,‘HUA01’);where语句中的 in 用来指定范围,范围中的所有值均可进行匹配。in操作符的功能or也可完成。但in 更清楚简洁。
  5. select prod_name,prod_price from product where not vend_id = ‘DEL01’ order by prod_name;
    where 语句中的not用来否定其后跟的所有条件。

《SQL必知必会》-学习记录。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值