我需要类似的东西:
select *
from table1
where {if PKID = MasterPKID - (that PKID should not be present as refNo in table2)}.
ie-652不应出现在表2中
我完全无能为力。
我们可以在一个查询中实现吗?
答案 0 :(得分:2)
使用Not exists
select *
from table1 a
where PKID = MasterPKID
and not exists (select 1 from table2 b where a.PKID = b.refno)