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 =''
set @pwd='xxxxxxx'
if exists (select * from 学生信息 where 学号=@username and 姓名=@pwd)
print '登录成功'
else
print '登录失败'

sqlserver2012——EXISTS关键字的更多相关文章

  1. 数据库中in和exists关键字的区别

    数据库中in和exists关键字的区别 in 是把外表和内表作hash join,而exists是对外表作loop,每次loop再对内表进行查询. 一直以来认为exists比in效率高的说法是不准确的 ...

  2. mysql 数据操作 多表查询 子查询 带EXISTS关键字的子查询

    带EXISTS关键字的子查询 EXISTS关字键字表示存在. EXISTS 判断某个sql语句的有没有查到结果 有就返回真  true 否则返回假 False 如果条件成立 返回另外一条sql语句的返 ...

  3. if exists和if not exists关键字用法

    在sql语名中,if not exists 即如果不存在,if exists 即如果存在. 下面学习下二者的用法. a,判断数据库不存在时 代码示例: if not exists(select * f ...

  4. Mysql中EXISTS关键字用法、总结

    在做教务系统的时候,一个学生(alumni_info)有多个教育经历(alumni_education),使用的数据库是mysql,之前使用左链接查询的,发现数据量才只有几万条时,查询就很慢了,早上想 ...

  5. exists和not exists关键字

    表A ID NAME 1    A1 2    A2 3  A3 表B ID AID NAME 1    1 B1 2    2 B2 3    2 B3 SELECT ID,NAME FROM A ...

  6. sql server if exists和 if not exists 的关键字用法

    if exists和if not exists关键字用法   1.介绍  if not exists 即如果不存在,if exists 即如果存在 2.使用  a.判断数据库不存在时  if not ...

  7. mysql中exists、not exists的用法

    exists 关键字是判断是否存在的,存在则返回true,不存在则返回false, not exists则是不存在时返回true,存在返回false: 1. 最常用的if not  exists用法: ...

  8. SQL语句——exists和in区别

    表结构及数据 user表 order表 in select * from table A where id in (xxxxxxxxxxx):满足条件的数据会被查出来: 先查询子查询的表,然后将内表. ...

  9. Python-select 关键字 多表查询 子查询

    sql 最核心的查询语句!!!! 增删改 单表查询 select语句的完整写法 关键字的书写顺序 执行顺序 多表查询 笛卡尔积 内连接 左外连接 右外连接 全外连接 通过合并左外连接和右外连接 子查询 ...

随机推荐

  1. pip3 Fatal error in launcher: Unable to create process using '"' [转]

    在新环境上安装python的时候又再次遇到了这个情况,这次留意了一下,发现原来的文章有错误的地方,所以来更新一下,应该能解决大部分的问题. 环境是win8,原来只安装了python2.7.后来因为要用 ...

  2. intellij idea使用技巧

    1 小窗口脱离了主窗口的解决办法 只要将floating mode和windowed mode取消掉就可以了,当选择上了floating mode和windowed mode之后会打一个勾,再次点击勾 ...

  3. Python中的staticmethod和classmethod

    谈谈Python中的staticmethod和classmethod 首先值得说明的是staticmethod和classmethod都是python中定义的装饰器,用的时候需要在前面加@ 即@sta ...

  4. d[k]=eval(k)

    lk = ['oid', 'timestamp', 'signals', 'area', 'building', 'city', 'name', 'floor', 'industry', 'regio ...

  5. Java for LeetCode 112 Path Sum

    Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...

  6. appium-andriod自动化实现注意项

    注意项: 1.appium需要全局安装,否则run test case 报错“appium not installed” 2.启动appium命令 node /Applications/Appium. ...

  7. webpack-dev-server原理及要点笔记

    webpack-dev-server启动了一个使用express的Http服务器,这个服务器与客户端采用websocket通信协议,当原始文件发生改变,webpack-dev-server会实时编译. ...

  8. 《C prime plus (第五版)》 ---第11章 字符串和字符串函数

    11-1:字符串表示和字符串I/O 1.首先先通过一个整体的例子来初步了解建立,读入和输出字符串的几种方式. #include<stdio.h> #define MSG "你一定 ...

  9. easyui datagrid行合并

    easyui datagrid行合并 合并方法 /** * EasyUI DataGrid根据字段动态合并单元格 * 参数 tableID 要合并table的id * 参数 colList 要合并的列 ...

  10. plugin scala is incompatible with current installation

    源文链接:http://stackoverflow.com/questions/31927516/plugin-scala-is-incompatible-with-this-installation ...