我对这个查询的结果完全感到困惑:
select count(*) from my_tab mt
where mt.stat = '2473'
and mt.name= 'Tom'
and exists (select * from company_users@colink.world cu,
personnel_records@colink.world pr
where cu.user_id = pr.user_id
and mt.name = pr.name
and mt.stat = cu.stat
)
回报:1
company_users@colink.world 中有 0 条记录,stat='2473',为什么它为存在返回 true?
如果我像这样更改查询,它将返回 0:
select count(*) from my_tab mt
where mt.stat = '2473'
and mt.name= 'Tom'
and exists (select * from company_users@colink.world cu,
personnel_records@colink.world pr
where cu.user_id = pr.user_id
and mt.name = pr.name
and cu.stat = '2473'
)
更新好的,这真的很奇怪。为了看看会发生什么,我从另一个数据库(DB Links 引用的那个)执行了查询,它给出了不同的(正确的)结果。
select count(*) from my_tab@mylink.world mt
where mt.stat = '2473'
and mt.name= 'Tom'
and exists (select * from company_users cu,
personnel_records pr
where cu.user_id = pr.user_id
and mt.name = pr.name
and mt.stat = cu.stat
)
返回 0(如预期的那样)。