SQL Server 数据库中的 ALL、SOME 和ANY
ALL、SOME 和 ANY是SQL Server 三个比较运算符,其中 SOME 和 ANY 是等效的。
SOME 或 ANY:当表达式与子查询返回的至少一个值比较时满足比较条件, SOME 或 ANY 就返回 TRUE。否则返回 FALSE
ALL :当表达式与子查询返回的所有值比较时满足比较条件, ALL 就返回 TRUE。否则返回 FALSE
create table test01 ( num int)
insert into test01
select 5 union
select 6
create table test02 (num int)
insert into test02
select 2 union
select 3 union
select 6 union
select 7select * from test01
select * from test02
– test01 表数据 5和 6
– test02表数据 2,3,6,7
select num as num1 from test02 where num > all(select num from test01 )
select num as num2 from test02 where num > any(select num from test01 )
select num as num3 from test02 where num > some(select num from test01)
select num as num4 from test02 where num = all (select num from test01 )
select num as num5 from test02 where num = any(select num from test01 )
select num as num6 from test02 where num = some(select num from test01)
select num as num7 from test02 where num <> all (select num from test01 )
select num as num8 from test02 where num <> any (select num from test01 )
select num as num9 from test02 where num <>some(select num from test01)
从上面测试结果看:= any 或 = some 与平时使用的 in 是等效的
添加链接描述
SQL Server 数据库中的 ALL、SOME 和ANY相关推荐
- 在ASP.NET中将图片存储到Sql Server数据库中
在ASP.NET中将图片存储到Sql Server数据库中 http://hi.baidu.com/rayshow/blog/item/360e8ff9662c8b5a252df268.html 索引 ...
- 清空SQL Server数据库中所有表数据的方法(转)
清空SQL Server数据库中所有表数据的方法 其实删除数据库中数据的方法并不复杂,为什么我还要多此一举呢,一是我这里介绍的是删除数据库的所有数据,因为数据之间可能形成相互约束关系,删除操作可能陷入 ...
- mysql raiserror_RAISERROR在SQL Server数据库中的用法
raiserror 是由单词 raise error 组成 raise 增加; 提高; 提升 raiserror 的作用: raiserror 是用于抛出一个错误.[ 以下资料来源于sql ser ...
- SQL Server数据库中、获得刚插入新记录的自动ID号
以下的文章主要是介绍在SQL Server数据库中正确获得刚插入一条新记录的自动ID号的实际操作过程,下面就是文章对其的主要内容的具体描述,望大家在浏览之后会对其有更深的了解. 使用[IDENT_CU ...
- 从sqlserver中数据写入mysql_[SQL Server]SQL Server数据库中如何返回INSERT INTO语句插入/写入数据后的记录值(比如ID等)?...
问题描述 SQL Server数据库中,有时候当我们使用INSERT INTO语句写入数据后,需要返回写入数据对应的自增ID或者GUID,以便根据此记录进行后续的操作.那么SQL语句如何实现返回记录值 ...
- SQL Server数据库中使用sql脚本删除指定表的列
在SQL Server数据库中删除某一列,使用数据库管理工具直接可视化操作是很简单的,但是如果要用sql脚本呢?可能你会说很简单,直接用 ALTER TABLE [要删除的字段所在的表名] DROP ...
- 浅析SQL Server数据库中的伪列以及伪列的含义
浅析SQL Server数据库中的伪列以及伪列的含义 原文:浅析SQL Server数据库中的伪列以及伪列的含义 本文出处:http://www.cnblogs.com/wy123/p/6833116 ...
- SQL Server数据库中批量导入数据的四种方法总结
在软件项目实施的时候,数据导入一直是项目人员比较头疼的问题.其实,在SQL Server中集成了很多成批导入数据的方法.有些项目实施顾问头疼的问题,在我们数据库管理员眼中,是小菜一碟.现在的重点就是, ...
- 通过VB向SQL Server数据库中录入数据
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 一.数据录入 通过VB向SQL Se ...
- 如何在SQL Server数据库中加密数据
如何在SQL Server数据库中加密数据 为了防止某些别有用心的人从外部访问数据库,盗取数据库中的用户姓名.密码.信用卡号等其他重要信息,在我们创建数据库驱动的解决方案时,我们首先需要考虑的的第一条 ...
最新文章
- 获取数组第N个元素的方法
- [LeetCode] Maximum Subarray 最大子数组
- 华为云交付项目服务器配置表,云端服务器配置表
- android低功耗蓝牙连接失败_低功耗蓝牙 AoA定位系统为室内定位和资产跟踪 提供亚米级精度位置服务...
- 中间件及tomcat的内存溢出调优
- NLP CV ML future
- Azkaban编译和安装模式
- 搜索引擎lucene
- 利用Group Conv在单个CNN中实现集成学习
- matlab expotest,软硬件协同开发在电机控制的应用-matlabexpo2019.PDF
- SAP表维护自动带出对象属性
- 转:This Android SDK requires Andr...ate ADT to the latest
- 计算机语言缩写 dos,dos是什么意思 dos缩写中英全称是什么
- Matplotlib之散点图绘制
- 超简单!一部手机就能提取视频中的语音转换成文字
- win10如何在当前目录打开cmd窗口
- VirtualBox AndroidX86 网络设置
- python猫抓老鼠_利用python如何实现猫捉老鼠小游戏
- 我给你们做了一个金钱豹头像助手,虎年祝大家今年暴富
- IDEA代码规约插件灵狐安装