添加表数据
1 insert into car values(' ',' ',' ', ' ',' ');
2 insert into car(字段1,字段2,....) values(值1,值2,.....);
3 insert into car set 字段1=值一,字段2=值2,...;
修改表数据
update car set 字段1= 值 where 字段2=值
删除表数据
delete from 表名 where 字段1 = 值
================简单查询===============
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>=40and 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 排队
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 10,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;