1、返回TRUE或者FALSE
如果exists查詢存在,則能查詢出來
select a.* From 成績信息 a where exists(select * from 考試安排 b where b.考試編號=a.考試編號 and b.考試編號=‘0801’)
2、判斷用戶登錄
declare @username varchar(16) declare @pwd varchar(32) set @username ='201905132' set @pwd='xxxxxxx' if exists (select * from 學生信息 where 學號=@username and 姓名=@pwd) print '登錄成功' else print '登錄失敗'