2018-10-26

2018-10-26  本文已影响21人  By丶久绊成影

回顾

必须用命令完成的

一、插入数据

insert into 表名 (列名)values (新值);

二、删除数据

update 表名  set 列名  =  新值  where 条件

三、删除数据

delete  from 表名 where 条件 

四、查询

  1. 查询所有列数据
  2. 查询部分的数据
  3. 模糊查询
  4. 分组查询
  5. 函数的使用

五、

  1. 数据库得基本知识
  2. 至少要明白 用图形界面建表和建库
  3. 使用图形界面添加之间的关系和约束

多表的连接查询

  1. 内连接
    inner join 表名 on 条件
    内连接是两张表中的数据都有的才会显示出来。
    例如:两张表的内连接查询
    select 列名 from 表名 as 别名 inner join另外一张表名
    as 别名 on 两张表连接的条件

题 :用我们刚才新建的两张表,查询出有成绩的学生信息?

题: 请用我们刚才新建的两张表, 查询出没有成绩的学生信息

----查询所有没有成绩的学生 运用了子查询
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
上一篇 下一篇

猜你喜欢

热点阅读