SELECT cName,score FROM course,sc WHERE sc.cNo = course.cNo AND sNo = (SELECT sNo FROM student WHERE sName = '王兵');
时间: 2024-06-10 07:06:19 浏览: 156
您想查询学生王兵所选的课程名和分数,正确的SQL语句应该是:
SELECT cName, score FROM course, sc
WHERE sc.cNo = course.cNo
AND sc.sNo = (SELECT sNo FROM student WHERE sName = '王兵');
相关问题
CREATE VIEW V_SCG AS SELECT Sno,Sname,Cname,Score,Credit from student,grade,course WHERE grade.Sno = student.Sno AND grade.Cno = course.Cno AND Cno = '0001'; 哪里错了
在这个 SQL 查询语句中,FROM 子句中的表 student、grade、course 没有使用 JOIN 操作符链接,而是使用了逗号分隔,这会导致查询结果出现笛卡尔积,即每个表中的每一行都与其他表中的每一行进行组合,从而导致查询结果出现重复数据。解决这个问题的方法是使用 JOIN 操作符来链接这些表,并在 ON 子句中指定连接条件。另外,查询中的 Cno = '0001' 应该指定表的别名,例如 course.Cno = '0001'。修改后的 SQL 查询语句如下所示:
```
CREATE VIEW V_SCG AS
SELECT Sno,Sname,Cname,Score,Credit
FROM student
JOIN grade ON student.Sno = grade.Sno
JOIN course ON grade.Cno = course.Cno
WHERE course.Cno = '0001';
```
delete from sc from sc join student on sc.sno=student.sno from sc join course on sc.cno=course.cno where student.sdept ='计算机系'and grade <60 and cnamne='java'对不对
这个 SQL 语句有语法错误,正确的语句应该是:
```sql
DELETE sc FROM sc
JOIN student ON sc.sno = student.sno
JOIN course ON sc.cno = course.cno
WHERE student.sdept = '计算机系' AND sc.grade < 60 AND course.cname = 'java';
```
这条 SQL 语句的作用是删除选修了“java”课程且所在学生所在院系为“计算机系”且该门课程的成绩低于60分的记录。