1、要求使用myschool数据库 中的学生表 student 实现下列操作: 1.》要求查询全部的学生,按照出生年月降序 2.》要求查询学号是10002的学生 3.》修改学号为10003的学生信息,新名字叫张三,性别为男,地址为湖南长沙 4.》删除学号为10007的学生信息 5.》查询logic java成绩是小于60的学生信息(子查询) 6.》查询所有学生信息,年级编号是 2,3的,使用in 7.》查询所有学生信息,年级编号不是 2,3的,使用not in 8.》如果成绩有等于70的,就查询全部学生 exists 9.》如果成绩没有大于60分,就查询全部学生
时间: 2024-02-05 20:14:16 浏览: 71
1. 查询全部学生,按照出生年月降序:
```sql
SELECT * FROM student ORDER BY birth DESC;
```
2. 查询学号是10002的学生:
```sql
SELECT * FROM student WHERE id = '10002';
```
3. 修改学号为10003的学生信息,新名字叫张三,性别为男,地址为湖南长沙:
```sql
UPDATE student SET name = '张三', gender = '男', address = '湖南长沙' WHERE id = '10003';
```
4. 删除学号为10007的学生信息:
```sql
DELETE FROM student WHERE id = '10007';
```
5. 查询logic java成绩是小于60的学生信息(子查询):
```sql
SELECT * FROM student WHERE id IN (SELECT id FROM score WHERE course = 'logic java' AND grade < 60);
```
6. 查询所有学生信息,年级编号是 2,3的,使用in:
```sql
SELECT * FROM student WHERE grade IN (2,3);
```
7. 查询所有学生信息,年级编号不是 2,3的,使用not in:
```sql
SELECT * FROM student WHERE grade NOT IN (2,3);
```
8. 如果成绩有等于70的,就查询全部学生:
```sql
SELECT * FROM student WHERE EXISTS (SELECT * FROM score WHERE student.id = score.id AND grade = 70);
```
9. 如果成绩没有大于60分,就查询全部学生:
```sql
SELECT * FROM student WHERE NOT EXISTS (SELECT * FROM score WHERE student.id = score.id AND grade > 60);
```
阅读全文