我正在尝试运行这个全文搜索查询。我需要在两个表上进行全文搜索。如果任何一个表都在任何一个表中,我需要从第一个表中返回记录。
select R.* from Request R
inner join Patients P on R.PatientID = P.PatientID
inner join containstable(Request,(*),@keywords)AS KEY_TBL
ON R.RequestID = KEY_TBL.[Key]
full outer join
(select R.* from Request R
inner join Patients P on R.PatientID = P.PatientID
inner join containstable(Patients,(*),@keywords) AS KEY_TBL2
ON P.PatientID = KEY_TBL2.[Key]) as b on R.RequestID = b.RequestID
答案 0 :(得分:1)
我所需要的只是一个联盟,而不是一个完整的外部联盟。
select R.* from Request R
inner join Patients P on R.PatientID = P.PatientID
inner join containstable(Request,(*),@keywords)AS KEY_TBL
ON R.RequestID = KEY_TBL.[Key]
UNION
select R.* from Request R
inner join Patients P on R.PatientID = P.PatientID
inner join containstable(Patients,(*),@keywords) AS KEY_TBL2
ON P.PatientID = KEY_TBL2.[Key]