
而 >any 表示只要比条件当中的任意一个大则为真,即为大于最小值;
<any 表示只要比条件当中的任意一个小则为真,即小于最大值。
给你些例子:in 是 确定集合的
SELECT au_lname, state
FROM authors
WHERE state IN ('CA', 'IN', 'MD')
结果:
au_lname state
-------- ----
Yokomoto CA
DeFrance IN
Stringer CA
MacFeatherCA
KarsenCA
Panteley MD
HunterCA
all 是查询还可以是子查询
如:
select name from edit
其中name前省略了all.
name前可以加ALL|DISTINCT
all是所有记录.
distinct是不重复的。
带【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:
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
in是包含在条件中的其中任意一个就行where 职称 in("教授","副教授","工程师"),只要职称满足其中一个就行了。
any忘了
不是必须包括where,查询不需要条件,就可不用,如查询表中所有记录:
sele * from 表名
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)