Non-pairwise和pairwise多橍位子查询
来源:互联网 发布:如何升级mac os x系统 编辑:程序博客网 时间:2024/04/28 03:37
进公司后同事第一次帮我讲解pl/sql教程的时候,我对一个多橍位子查询的例子一直不明白, 教程上是说pairwise 和non-pairwise两种方式的子查询有区别,但到底什么区别,并没有指出,同事应该很清楚,但或许觉得很简单吧,让我自己去想,可惜我脑子有时候就是转不过弯,于是一直都没有想明白,在网上也没查到什么实际的例子来让自己眼前一亮.今天逛到一blog正好有写到相似问题,博主没有想到用pairwise形式的子查询来解决他的问题,只得用了一个procedure,但正好这个例子帮助了我,呵呵。。
于是自己做了个表来测试pairwise 和non-pairwise的区别
表结构及数据如下:
create table ttest(deptno number,
job varchar2(10),
sal number)
insert into ttest values(1,'a',1500)
insert into ttest values(5,'a',900)
insert into ttest values(1,'b',1500)
insert into ttest values(4,'a',2100)
insert into ttest values(5,'c',1500)
select * from ttest
意图从表中选出工资(sal)大于1000小于2000的记录
Non-pairwise多橍位子查询:
select *
from ttest
where deptno in (select deptno
from ttest
where 2000 > sal
and sal > 1000)
and job in (select job
from ttest
where 2000 > sal
and sal > 1000)
结果:
Pairwise 多橍位子查询:
select *
from ttest
where (deptno, job) in (select deptno, job
from ttest
where sal > 1000
and sal < 2000)
结果:
当然,第二种方式才是我们想要的结果。
我要说的是non-pairwise一例取的数据
我们可以看为这样一个过程:
取出sal介于1000和2000之间的deptno,作为一个集合,例如集合A;
取出sal介于1000和2000之间的job,作为一个集合,例如集合B;
如果一条记录的deptno属于集合A且它的job属于集合B,则返回记录。
这样出现的一个问题就是若一条记录的sal并不在于条件范围内,但deptno属于集合A并job属于集合B,那么这条记录亦会被返回.
- Non-pairwise和pairwise多橍位子查询
- OATS PK Pairwise Testing
- 深入浅出 pairwise 算法
- 5.7 Pairwise Swap
- Pairwise Sum and Divide
- Pairwise Sum and Divide
- Learning to Rank PairWise 训练
- 1305 Pairwise Sum and Divide
- 1305 Pairwise Sum and Divide
- 【测试算法】深入浅出Pairwise 算法
- PICT(Pairwise Independent Combinatorial Testing tool)
- [几行Matlab代码之]pairwise distances
- 使用PICT工具完成Pairwise组合测试
- 51nod 1305:Pairwise Sum and Divide
- 51NOD 1305 Pairwise Sum and Divide
- 51nod1305 Pairwise Sum and Divide
- 51nod1305 Pairwise Sum and Divide
- PITF(Pairwise Interaction Tensor Factorization)分解
- ARMSYS2440开发板使用FAQ!
- 掌握好这30条职场经验
- myEclipse建立与sql server连接
- URL重写的几种实现方式的总结
- 用最简单的方法来为自己的软件产生序列号.
- Non-pairwise和pairwise多橍位子查询
- Windows程序调试--Dr.Watson调试
- 五种能力支撑美好人生
- 中石油称澳洲资产缩水近900亿无中生有
- 狼的处世哲学
- Windows程序调试--VC调试器使用
- IPTV概念释疑(不断更新)
- Chrom的最小字体设置(minimum font size)
- attach解释