sql里in,all,any,some的区别和具体应用范围
2014-05-04 15:00
435 查看
in 是 确定集合的 SELECT au_lname, state FROM authors WHERE state IN ('CA', 'IN', 'MD') 结果: au_lname state -------- ---- Yokomoto CA DeFrance IN Stringer CA MacFeather CA Karsen CA Panteley MD Hunter CA 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;
相关文章推荐
- SQL中ALL、Any、Some的区别
- sql之exsists, in, all, any, some,
- mysql之any,in,some,all的区别
- [数据库与SQL] - No.1 in、exists、all、any用法与区别
- sqlserver中All、Any和Some用法与区别
- SQL中exists,any,all,some,in的问题
- sql查询关建字之-exists, in. all, any, some
- sql中exsists, in, all, any, some,
- mysql之any,in,some,all的区别
- sql中用于子查询的几个关键词 any(some是 any的别名),all,in,exists
- SQL中exists,any,all,some,in的问题
- LINQ体验(7)——LINQ to SQL语句之Group By/Having和Exists/In/Any/All/Contains
- any,some,all的用法和区别
- LINQ to SQL语句小结之 Exists/In/Any/All/Contains(转载)
- This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'
- Oracle子查询中any、some、all之间的区别
- MySQL嵌套查询“LIMIT & IN/ALL/ANY/SOME”错误解决方法
- sql中all,any,some用法
- SQL中exists,any,all,some,in的问题
- SQL中All, Any, Some的意思