MasterID | PartID
1 1
2 3
3 5
部分表:
PartID | PartName | DeleteDate
1 Part1 NULL
2 Part2 NULL
4 Part4 NULL
5 Part5 08-04-2017
结果表:
MasterID | PartID
2 3
3 5
这两个表存在于两个不同的数据库和我需要验证一个SQL查询来获取记录,如果主表有PartID
不在Part表和Master表具有在零件表中被删除的任何PartID
(即, DeleteDate
IS NOT NULL)
我想用下面的查询,但没有得到预期的结果
Select
*
FROM DBNAME.DBO.Master
Where PartID in (
Select
PartID
from Part)
and PartID not in (
Select
PartID
from Part
where DeleteDate is NOT NULL)
请让我知道我可以做到这一点
在发布代码或东西,应该是在等宽字体,选择粘贴什么,然后按{}键,保持它对我们来说可读! –