SQL的all、any和some的用法
SQL的all、any和some的用法
1、首先t1和t2表如下: t1(2,3) t2(1,2,3,4)
2、all,any,some 的子查询
2.1 all 父查询中的结果集大于子查询中每一个结果集中的值,则为真
select * from t2 where n>all (select n from t1) ---4
2.2 any,some 父查询中的结果集大于子查询中任意一个结果集中的值,则为真
select * from t2 where n>any(select n from t1) --3 4
select * from t2 where n>some(select n from t1) --3 4
2.3 any 与子查询in相同
select * from t2 where n=any (select n from t1) ---2 3
xxselect * from t2 where n in (select n from t1) ---dsd2 3
2.4 any 与not in
1)any
or作用 父查询中的结果集不等于子查询中的a或者b或者c,则为真
select * from t2 where n <>any(select * from t1) -----1 2 3 4
2)not in
--and作用 父查询中的结果集不等于子查询中任意一个结果集中的值,则为真
select * from t2 where n not in(select * from t1) ---1 4
总结
以上是生活随笔为你收集整理的SQL的all、any和some的用法的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: js some every数组方法的区别
- 下一篇: 非知名猎头Henry 和你谈-高薪是怎么