sqlserver in 和 exist 子查询
1 in 子查询
1 use StudentManageDB 2 go 3 --select StudentName from Students 4 --where StudentId=(select StudentId from ScoreList where SQLServerDB>80) 5 select StudentName from Students 6 where StudentId in (select StudentId from ScoreList where SQLServerDB>80)
1 use StudentManageDB 2 go 3 select StudentId,StudentName from Students 4 where StudentId not in(select StudentId from ScoreList)
2.exist 子查询
1 use StudentManageDB 2 go 3 if exists(select * from ScoreList where CSharp<60) 4 print '本次考试内容较难' 5 else 6 print '本次考试内容适中' 7 8 --NOT EXISTS的使用 9 if not exists(select * from ScoreList where CSharp<60) 10 print '本次考试内容适中' 11 else 12 print '本次考试内容较难'