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,不会进行比较。
?
|