【发布时间】:2017-04-15 15:11:10
【问题描述】:
架构:
学生(snum:整数,sname:char(30),major:char(25),level:char(2),age:整数)
教师(fid:整数,fname:char(30),deptid:整数)
类 (cname: char(40), meet_at: char(20), room: char(10), fid: integer | fid REFS 教员.fid)
已注册 (snum: integer, cname: char(40) | snum REFS student.snum, cname REFS 类名)
我想打印所有级别的学生的级别和年龄 除了“JR”。我知道我可以以简单的方式应用此查询。但我想加入我们的行列
我的尝试:
select s.levels as Seniority,s.age as Age
from student s
where s.levels not in (
select a.levels
from student a
where a.levels='JR');
这没有给我预期的答案。我是不是做错了什么?
【问题讨论】:
-
你不想
join?!! -
我想通过JOINS来做这个
-
喜欢这个
Select s.level, s.age from student s where s.level != 'JR'?? -
我认为您没有使用联接。您正在使用子查询。
-
你是什么意思,这没有给你预期的答案?请用输入输出说明。