增加插入字段
顺序插入
insert (into)可省略t1 values(1,'zzf',20)
对应特定字段插入
insert (into)可省略 t1 (name,age)values('zzf',20)
查询旧表结果插入新表
insert into t1 (name,age)select name,age from t2;
删除字段,清空表
delete from t1 where name='zzf';
delete from t1; 删除表内数据,但是自增id会记忆
truncate table t1 清空数据包括自增
修改
update from t1 age=20 where name='zzf';
单表查找
select (distinct去重) from t1 where group by having order by limit 字段可以取别名
concat()拼接字段
concat_ws(x,)拼接字段 x为连接符
round()四舍五入
ceil ()向上取整
floor()向下取整
upper()
lower()
where 可进行逻辑判断 可运用 内置函数处理
between 10 and 20
in (,)
比较运算 ><= !=
逻辑 and or not
正则 like ‘%’
group by 后 select后一定是聚合函数 并且后面条件约束可直接运用聚合函数
聚合函数
max()
min()
avg()
count()记录组内数目
sum()
group_concat()拼接组内字段
having 对于聚合函数进行筛选过滤
order by 进行排序
desc 降序
asc 升序
limit 限制输出
limit 1;
limit 2,2;第三行开始输出2两行
子查询 一条查询结果作为另一条的查询条件
单行><
多行查询all any in
select *from emp where age> any(select age from emp where salary>3);