修改数据
update 数据表名 set 字段=值 where 条件
update stu2 set score=100 where score>80
删除数据
delete from 表名 where 条件
备注:如果使用delete 语句后面没有where 子句 会删除数据库中所有的记录
truncate 数据表名
数据查询
select * (字段名) from 数据表名
where 条件
group by 条件 对查询后的结果进行分组
order by 条件 参数 desc asc 对查询结果进行排序
having 子句 满足的第二个条件
(1)使用select 语句查询一个数据表
1select * from user * 所有的字段
as 字段起别名
1.查询所有的字段 *
2.查询指定的字段 select 要查询的字段 from 表名
3查询指定的数据 select where 比较运算符子句
select * from 表名 where score between 80 and 100
4.带关键字的in
select 字段* where 条件 not in (元素1,元素2,元素3)
select * from stu where not in(70,80,90)
5.between and
6.like 模糊查询
% 多个字符 _ 一个
7.is null 查询空值
select * from stu where score is null
8.and 联合多条件查询
select name from stu where sex='女' and age between 18 and 20 and address like
'北京%' and rich='富有'
9 or 联合 查询
10. 使用关键字 去重查询
distinct
select distinct 字段 from 表名
select distinct 专业 from stu
11.使用order by 对查询结果进行排序
asc 升序 desc 降序
order by 字段名 asc
12.group by
group_concat()函数 将每组所有的记录的字段值都显示
13.limit
限制查询输出的数量
select name from stu order by score desc limit 10
14.聚合函数
(1)count() 返回满足条件的记录的个数
(2)sum() 求和
(3)avg()平均值
(4)max()最大值
(5)min()最小值