SQL语法:查询此表有另外一个表没有的数据

select bei.ExamItem_Code2,*from PeisPatientExamItem ppei
join PeisPatientFeeItem ppfi
on ppfi.ID_PatientFeeItem=ppei.ID_PatientFeeItem
join PeisPatient pp
on pp.ID_Patient=ppfi.ID_Patient
join BasExamItem bei
on bei.ID_ExamItem=ppei.ID_ExamItem
where pp.ID_Patient=5 and
bei.ExamItem_Code2 not in (select ExamItem_Code_R from herpeishkjt1..PeisPatientExamItem)

查询体检号为5的,herpeishkjtbfyy库中有ExamItem_Code2,但是herpeishkjt1库中没有ExamItem_Code_R 的所有数据。

原文地址:https://www.cnblogs.com/hxp-wwx/p/7989713.html