sqlserver两个数据库联合查询
时间:2021-07-01 10:21:17
帮助过:62人阅读
a.Id 医嘱ID ,
a.MedordType 类目 ,
a.InhosID 住院号 ,
a.ExecOfficeID 科室编码 ,
a.StartTime 开始时间 ,
c.PatientName 姓名 ,
d.Office 科室名字
FROM 数据库A.dbo.Mst_LongDoctorAdvice a
--LEFT JOIN NEWHISMessageWarning.dbo.MessageWarning b ON 1 = 1
LEFT JOIN 数据库A.dbo.BaseCom_Patient c
ON a.InhosID
= c.Diagnoseid
LEFT JOIN 数据库A.dbo.BaseCom_Office d
ON d.Officeid
= a.ExecOfficeID
WHERE a.Id
NOT IN (
SELECT yzID
FROM 数据库B.dbo.MessageWarning
WHERE yzlx
= 1 );
SELECT a.Id 医嘱ID ,
a.MEDORDTYPE 类目 ,
a.INHOSID 住院号 ,
a.EXECOFFICEID 科室编码 ,
a.STARTTIME 开始时间 ,
c.PatientName 姓名 ,
d.Office 科室名字
FROM 数据库A.dbo.Mst_TempDoctorAdvice a
--LEFT JOIN NEWHISMessageWarning.dbo.MessageWarning b ON 1 = 1
LEFT JOIN 数据库A.dbo.BaseCom_Patient c
ON a.INHOSID
= c.Diagnoseid
LEFT JOIN 数据库A.dbo.BaseCom_Office d
ON d.Officeid
= a.EXECOFFICEID
WHERE a.Id
NOT IN (
SELECT yzID
FROM 数据库B.dbo.MessageWarning
WHERE yzlx
= 2 );
sqlserver两个数据库联合查询
标签:style 联合查询 sqlserver 时间 sql font exec sid start