background image

某班学生和考试成绩信息分别如下表

Student 和表 Achievement 所示:

ID Name

1  Jack

2  Marry

3  Rose

4  Bob

5  John

6         Betty

7         Robert

ID         Mark

1         90

2         96

3         88

4         86

5         83

6         85

Student   , 表 Achievement

其中

ID 为学生的编号,Name 为姓名,Mark 为成绩,请针对以下问题,写出相应的 SQL 语句:

1、

        请查询成绩>85 分的学生的姓名;

Select Name from Student where id  in(select id from achievement where mark>85);

Select * from student where id in (select id from achievement where mark>85);

2、

        请查询成绩>=90 分的人数;

Select count(*) from ac where mark》=90;

Slect count(*) from achievement where mark>=90

3、

        Robert 此次考试考了 80 分,但是成绩没能录入表中,请将其成绩添加进去;

Insert into ac(id,mark)values (

‘7’,‘80’);

Insert into achievement(id,name) values (‘1’,’80’);

4、

        请将 Rose 的成绩修改为 87;

Update ac set mart=

‘87’where id=4;

Update achievement set mark=87 where id=3;

5、

        请删除 Betty 的记录;

Delete * from student where id=6;

Delete * from achievement where id=6;