标签:limit not 最简 去重复 and 数据库 聚合 重复 简单
1、最简单查询:
select * from car;
2、查询制定列:
select name oil,powers from car;
3、对查出的列名修改名字:
select name as ‘车名‘,oil as ‘油耗‘,powers as ‘动力‘ from car;
4、按条件查询:
select name,oil,powers from car where oil = 8.7;
5、多条件查询:
select name,oil,powers from car where oil = 8.7 or powers = 160;
select name,oil,powers from car where oil = 8.7 and powers = 160;
6、范围查询:
select * from car where price>=40 and price <=60;
select * from car where price between 40 and 60;
7、离散查询:
select * from car where powers = 130 or powers = 150 or powers = 170;
select * from car where powers in (130,150,170);
select * from car where powers not in (130,150,170);
8、模糊查询:
select * from car where name like ‘%宝马%‘;
select * from car where name like ‘_宝马%‘;
9、排序查询: asc 升序 desc 降序 order by
select * from car order by oil asc;
select * from car order by brand asc,price desc;
10、去重复查询: distinct
select distinct brand from car;
11、分页查询:
select * from car limit 5,5;
n;m = 5;
limit (n-1)*m,m; 【补充】
12、聚合函数查询:
count(列名) sum(列名) avg(列名) max(列名) min()
select count(*) from car;
select sum(price) from car;
select avg(price) from car;
select max(price) from car;
select min(price) from car;
标签:limit not 最简 去重复 and 数据库 聚合 重复 简单
原文地址:https://www.cnblogs.com/zhengleilei/p/9128652.html