MYSQL 寒假自学 2022 六(二)

select的使用

select * from product where pname = '海尔洗衣机';

select * from product where price = 800;
select * from product where price != 800;
select * from product where price <> 800;
select * from product where not (price = 800);


select * from product where price >=60;
select * from product where price between 200 and 1000;
select * from product where price >=200 and price<=1000;
select * from product where price >=200 && price<=1000;

-- 查询价格是200或800的所有商品
select * from product where price in(200,800);
select * from product where price = 200 or price = 800;
select * from product where price = 200 || price = 800;
-- 查询含有‘裤’字的所有商品
select * from product where pname like '%裤%';

-- 查询以'海'字开头的所有商品
select * from product where pname like '海%';

-- 查询第二个字为'蔻'的商品
select * from product where pname like '_蔻%';
--  _下划线匹配单个字符
-- 查询category_id为null的商品
select * from product where category_id is null;

select * from product where category_id is not null;
select least(10,5,20);
select least(10,5,20) as small_number;

select greatest(10,20,30);
select greatest(10,null,30);

注意,求最大最小值时,如果里面有一个null,结果直接为null,不会进行比较。

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值