新手区 关于 sql 语句的比较运算符=的使用

诸葛流年 · 2018年05月23日 · 最后由 回复于 2018年05月24日 · 1408 次阅读

表的结构
    Student(S#,Sname,Sage,Ssex)    学生表
    Course(C#,Cname,T#)        课程表
    SC(S#,C#,score)           成绩表
    Teacher(T#,Tname)         教师表
查询学过 “叶平” 老师所教的所有课的同学的学号、姓名;
select a.s# from student a ,teacher,course,sc WHERE teacher.tname='叶平'and course.t#=teacher.t# and sc.c#=course.c#and a.S#=sc.s#
最近复习数据库发现 s1.s#=student.s#=s2.s#,数据库中连续=会判断错误,需要使用 s1.s#=student.s# and s1.s#=s2.s#,请问这个是因为数据库只能使用单个的=符号吗

使用 select a.s# from student a ,teacher,course,sc WHERE teacher.tname='叶平'and course.t#=teacher.t# and sc.c#=course.c#=sc.s#

查询结果就是错误的

共收到 1 条回复 时间 点赞

是的。sc.c#=course.c#=sc.s# 不行,sc.c#=course.c#=1 也不行。具体为什么,留给大神来解答吧。。。

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册