马敏11

2020-07-31   阅读量: 954

Mysql

any和all组合运算符用法区别

扫码加入数据分析学习群


1、类型不同

这两个都是用于子查询的,any 是任意一个,all 是所有。

2、用法不同

select * from student where 班级='01' and age > all (select age from student where 班级='02');就是说,查询出01班中,年龄大于 02班所有人 的 同学

相当于select * from student where 班级='01' and age > (select max(age) from student where 班级='02');

而select * from student where 班级='01' and age > any (select age from student where 班级='02');就是说,查询出01班中,年龄大于02班任意一个的同学

相当于 select * from student where 班级='01' and age > (select min(age) from student where 班级='02');


扩展说明:

ANY函数简介

函数功能:判断数组中元素是否为0语法格式:B = any(A) 判断数组中元素是否是一个非零元素或逻辑1(true)。

any函数会忽略掉数组中的NaN项(not a number)。如果A是空的,any(A)返回逻辑0(false)。如果A是一个向量(1行n列或n行1列的矩阵),

只要A中有一个非零元素或A中有一个元素是逻辑1,any(A)返回逻辑1(true),否则(A中所有元素均为0)返回逻辑0(false)。

如果A是一个矩阵,any函数把A的每一列当做一个向量,any(A)返回一个行向量。

如果A是一个多维数组,any(A)对A中第一个非奇异维进行判断。B = any(A,dim)dim指定了要进行判定的维数。

例如,对于二维数组, any(A, 1)把A中每一列看做一个向量,然后进行判断;any(A, 2)把A中每一行看做一个向量,然后进行判断。

39.9414 4 2 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子