oracle 使用in的灵异事件

今天写oracle语句时发现一个奇怪的问题,纠结了很久没有找到原因。求大牛解惑。问题精简如下:

select seq,info ,topic from system.help where seq in   (select distinct seq from system.help where seq=20);  -----(1)

与 select seq,info ,topic from system.help where seq in(20)------(2)所得的结果差距很大。

众所周知select distinct seq from system.help where seq=20的结果当然是20。从语句上看(1)和(2)是应该等效的,但是(2)的查询结果是对的,仅有10行,但是(1)的中seq不仅仅有20的对应行值,而且有很多行seq为0,行数为500……(汗,这些0从哪来的,help表总共才71行。oracle示例数据库中有help表)

select seq,info ,topic from system.help where seq=  (select distinct seq from system.help where seq=20);  -----(3)这句是和(2)一样,可以取得正确的结果。

之后在其他人的电脑上测试,(1)语句又灵异的和(2)的一样了……神马情况……为神马我的电脑不行?

在我的电脑上(1)为神马不对呢?配置问题?还是语句问题?大家有答案的话可以去回答我的博文,有园豆可以拿哇

http://home.cnblogs.com/q/26334/

分享到: 更多
原文地址:https://www.cnblogs.com/haisa/p/2093065.html