主题:这样写对么?
在看“转帖]简单SQL语句小结”精华帖子时看到这,
d.注意在做否定意义的查询是小心进入陷阱:
如,没有选修‘B2’课程的学生 :
select students.*
from students, grades
where students.sno=grades.sno
AND grades.cno <> ’B2’
上面的查询方式是错误的,正确方式见下方:
select * from students
where not exists (select * from grades
where grades.sno=students.sno AND cno='B2')
请问:我这么写对么?
select student.*
from students, grades
where student.sno=grades.sno
AND grade.cno NOT IN('B2')
d.注意在做否定意义的查询是小心进入陷阱:
如,没有选修‘B2’课程的学生 :
select students.*
from students, grades
where students.sno=grades.sno
AND grades.cno <> ’B2’
上面的查询方式是错误的,正确方式见下方:
select * from students
where not exists (select * from grades
where grades.sno=students.sno AND cno='B2')
请问:我这么写对么?
select student.*
from students, grades
where student.sno=grades.sno
AND grade.cno NOT IN('B2')