SQL数据库的基本操作
CURD操作/增删改查
1.插入语句:
insert into 表名(表的字段1,表的字段2)values(字段1的值,字段2的值);//字符串类型的加上引号
如:

2.删除语句:
delete from 表名 where 条件//比如:`name` = `luxp`
如:

3.修改语句:
update 表名 set 字段1 = “值”,字段2 = “值” where 条件//比如: update student set age = 18 where name='luxp'
如:

4.查询语句:
(1).select 字段1,字段2.。。from 表名 where 条件
limit 1:表示只查询记录中的一条
limit 5:表示查询5条
limit start,size 从第start位置查询size条
如:

(2).带查询限制的查询语句
select 字段 from 表名 where 条件 limit start,size
排序 order by
desc 根据字段的值 降序
asc 根据字段的值 升序
(3).带排序的查询语句
select 字段(*) from 表名 order by 字段 desc/asc limit start,size
如:

(4).分组统计查询
select count(*) from 表名 //获得所有行数
select count(*) as num from 表名 //将count结果作为一个字段名检索
如:

(5).分组 ground by 字段名 根据某个字段进行分组查询
//索引可以提高查询速度
//索引会降低插入,修改速度
如:

(6).求和 sum()
select sum(age) from student //求所有行数的age字段的总和
如:

(7).求平均值 avg()
select avg(age) from student//求年龄的平均值
如:

(8).查最大值max()与最小值min()
select max(age) from student
select min(age) from student
如:
