条件查询[where 关键字]
select * from product where price >60;
where后可用条件运算符> >= < <= = != <>不等
select * from product where price > 10 and price <100;
select * from product where price between 10 and 100;
逻辑运算 and , or , not
select * from product where price < 100 or price > 900;
like:模糊查询
_:代表一个字符
%:代表多个字符
select * from product where pname like '%饼%'
in 在某个范围中的值
select * from product where cno in(1,4,5);
asc 升序
desc 降序
select * from product order by price asc/desc
聚合函数
sum()求和 select sum(price) from product;
avg()求平均值 select avg(price) from product;
count()求数量 select count(*) from product;
max()
min()
子查询
select * from product where price > (select avg(price))from product);