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 本次考试内容较难

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...