mysql数据库1

 
desc 表名;  显示表结构
select * from student; 查看表格内容
alter table student rename to students;  修改表格名字
from students; 查看表
insert into students values(0,'高海',20,1.56,'女',1,0,'2018-10-27');  表里添加数据
修改表格内容
增加字段
like ‘% ’  模糊匹配 
占位符 ‘_ '
where id in(1,3) 只匹配 id 是 1,3
asc 是正序  desc是倒序   order随机排序
count(*) max () min()用法
sum()总和     avg() 用法平均值
group by 分组
group concat()
distinct 去重 和group by
limit _,_
select *from student order by rand();随机排序
select*from student order by rand() limit0,2;
having 和where group by 可以加where 条件,where条件必须加以group by 前面 having 是二次筛选
group by ---with rollup;算出列的总和;
inner join取交集
left join 以左边的表为标准匹配左边有的 若没有为空
right join
one on one
many on many
one on many
三表匹配
自关联
三表连查
区查省市
view 视图
修改试图
子查询
标量子查询查询班级学生平均查询大于平均年龄的学生查询班级学生的平均身高
行级子查询需求: 查找班级年龄最大,身高最高的学生行元素: 将多个字段合成一个行元素,在行级子查询中会使用到行元素
列级子查询查询还有学生在班的所有班级名字找出学生表中所有的班级 id找出班级表中对应的名字

猜你喜欢

转载自www.cnblogs.com/liang715200/p/10021486.html
今日推荐