码迷,mamicode.com
首页 > 数据库 > 详细

Oracle中 oracle中any,some,all用法

时间:2015-10-27 23:22:18      阅读:319      评论:0      收藏:0      [点我收藏+]

标签:

* Some在此表示满足其中一个的意义,是用or串起来的比较从句。

* Any也表示满足其中一个的意义,也是用or串起来的比较从句,区别是any一般用在非“=”的比较关系中,这也很好理解,英文中的否定句中使用any肯定句中使用some,这一点是一样的。

* All则表示满足其其中所有的查询结果的含义,使用and串起来的比较从句。

 

 

Any

带【any】的嵌套查询和【some】的嵌套查询功能是一样的。早期的SQL仅仅允许使用【any】,后来的版本为了和英语的【any】相区分,引入了【some】,同时还保留了【any】关键词。

any:

select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal >any(select sal from scott.emp where     job=‘MANAGER‘);

带any的查询过程等价于两步的执行过程。

    (1)执行“select sal from scott.emp where job=‘MANAGER‘”

 select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal >2975 or sal>2850 or sal>2450;

 

some

some:

select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal =some(select sal from scott.emp where     job=‘MANAGER‘);

 

 带some的嵌套查询与any的步骤相同。

    (1)子查询,执行“select sal from scott.emp where job=‘MANAGER‘”,其结果如图4.22所示。

    (2)父查询执行下列语句。

    ―――――――――――――――――――――――――――――――――――――

    select emp.empno,emp.ename,emp.job,emp.sal from scott.emp where sal =2975 or sal=2850 or sal=2450;

 

all

 

all 是查询还可以是子查询

如:

 

select name from edit

其中name前省略了all.

name前可以加ALL|DISTINCT

all是所有记录.

distinct是不重复的。

Oracle中 oracle中any,some,all用法

标签:

原文地址:http://www.cnblogs.com/zhuxiaolin/p/4915660.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!