sqlserver2012——EXISTS关键字

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 '登录失败'

 

posted @ 2019-05-19 15:26  风情单车  阅读(788)  评论(0编辑  收藏  举报