Mysql中any,some,all的用法以及区别 |
您所在的位置:网站首页 › 代言头衔的区别和用法 › Mysql中any,some,all的用法以及区别 |
文章目录
一、any,some,all介绍二、使用情况1.all逻辑运算符2.any和some运算符
提示:以下是本篇文章正文内容,下面案例可供参考 一、any,some,all介绍any,some,all是Mysql当中的逻辑运算符,作用是将子查询返回的单列值的集合与查询的单个值作比较。any,all,some前面需跟比较运算符(>, >=, all(select score from students where sclass=2); 结果: 2.any和some运算符any和some作用是一样的。 例如: select…from…where c > any(…) 或者 select …from …where c > some(…) 表示c列中的值要大于子查询中的任意一个值,即必须要大于子查询集中的最小值。同理可以推出其它的比较运算符的情况。 示例: 查询3班成绩至少大于2班成绩的学生信息: select * from students where sclass=3 and score > any(select score from students where sclass=2); select * from students where sclass=3 and score > some(select score from students where sclass=2);结果: |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |