我正在try 寻找以下两个查询的交集:
select distinct(id) from sval where val = 'True' and fid = 4044;
select distinct(id) from ival where fid = 3994 and val=0;
他们都返回了一份独一无二的id
英尺S的名单.
我通过执行以下操作找到交叉点(即重叠值):
select distinct(id)
from sval
where (val = 'True' and fid = 4044)
and exists(
select distinct(id) from ival
where fid = 3994 and val=0
);
上述说法正确吗?
奇怪的是,如果我对第一个查询做count
,对第二个查询做1,我得到的行数是252290
和22268
.
当我计算第三行时,你会认为它最多返回22268
,但我得到了252290
,你知道为什么会是这样吗?