sql server2000里面一个奇怪的问题

来源:百度知道 编辑:UC知道 时间:2024/06/25 17:22:33
select * from gljournal where journalid in (select pcombid from t_arprecord)
这个查询跑不出数据,但是这样的记录确实存在,不知道为什么,journalid是
gljournal 的主键,跟t_arprecord中的pcombid存在部分对应关系但不是全部,这点是确定的
写错了是 select * from gljournal where journalid not in (select pcombid from t_arprecord)

加了时间的条件就能出数据,不知道为什么
select * from gljournal where journalid not in (select pcombid from t_arprecord where etd<='2008-03-01')
这样就能出来

不是gljournal 里面记录数比arprecord 少,是比他多,所以我才要找gljournal 里面有但是t_arprecord 里面没有的
是in (1,2,3,4,5,6) not in (1,2,3)这样的关系,应该查出(4,5,6)的 但是现在没有记录

搂主的意思我明白了,大概数据是这样的吧。
表gljournal里的数据记录应该比t_arprecord中的记录少,所以not in 时没有满足条件的记录。
加上时间筛选后,t_arprecord 中筛选的纪录结果就会减少,这样的话就会有一些gljournal中针对的journalid 纪录被筛选掉,就有满足not in条件 (不包含在筛选结果集中的数据)的了。

搂主最好能说明一下你的意图,这样大家才能更准确地帮你指出错误之处。
---------------
补充:记录数1,2,3 not in (1,2,3,4,5)这样的条件是查不出结果的。因为not in 呵呵。
链表:select a.*,b.* from tablea a,tableb b where a.aid = b.bid and b.dateb<'2008-05-05'

"跟t_arprecord中的pcombid存在部分对应关系但不是全部"?我觉得你还是再仔细查下,否则如你所说,应该会出数据的

再仔细想一下表的链接怎么写