select name ,price + 10 as new price from product;
比较运算符
逻辑运算符
位运算符
条件查询
查询商品名称为“海尔洗衣机”的商品所有信息:
1
select * from product where pname = '海尔洗衣机';
查询价格为800商品
1
select * from product where price = 800;
查询价格不为800商品
1 2 3
select * from product where price != 800; select * from product where price <> 800; select * from product where not (price = 800);
查询商品价格大于等于60元的所有商品信息
1
select * from product where price >= 60;
查询商品价格在200到1000之间所有商品
1 2
select * from product where price between 200 and 1000; select * from product where price>=200 and price<=1000;
查询商品价格是200或800的所有商品
1 2 3
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;
查询含有’裤’字的所有商品
1
select * from product where pname llke '%裤%' -- %用来匹配任意字符
查询以’海’开头的所有商品
1
select * from product where pname like '海%';
查询第二个字为’蔻’的所有商品
1
select * from product where pname like '_蔻%' -- 下划线匹配单个字符
查询category_id为null的商品
1
select * from product where category_id is null;
查询category_id不为null分类的商品
1
- select * from product where category_id is not null;