回顾
必须用命令完成的
一、插入数据
insert into 表名 (列名)values (新值);
二、删除数据
update 表名 set 列名 = 新值 where 条件
三、删除数据
delete from 表名 where 条件
四、查询
- 查询所有列数据
- 查询部分的数据
- 模糊查询
- 分组查询
- 函数的使用
五、
- 数据库得基本知识
- 至少要明白 用图形界面建表和建库
- 使用图形界面添加之间的关系和约束
多表的连接查询
- 内连接
inner join 表名 on 条件
内连接是两张表中的数据都有的才会显示出来。
例如:两张表的内连接查询
select 列名 from 表名 as 别名 inner join另外一张表名
as 别名 on 两张表连接的条件
题 :用我们刚才新建的两张表,查询出有成绩的学生信息?
- 2、外连接
- 左外连接
查询出的结果是左表的信息全部显示, 右边表没有时间显示成null
- 左外连接
题: 请用我们刚才新建的两张表, 查询出没有成绩的学生信息
----查询所有没有成绩的学生 运用了子查询
select * from (select stu.id,stu.name ,stu.height,stu.tizhong,
scr.kemu,scr.chengji
from student as stu left join score as scr
on stu.id=scr.id) as xb where xb.kemu is null
----查询所有的学生成绩信息
select stu.id,stu.name ,stu.height,stu.tizhong,
scr.kemu,scr.chengji
from student as stu left join score as scr
on stu.id=scr.id
网友评论