产品表
pid modelnumber
1 a
2 b
3 c
ProductTransation
pid name description...
1 ball ball
2 bat cricket bat
我在产品表中为Modelnumber创建了fullText。
同名和& productTransaction table中的描述。
现在,如果我搜索modelnumber或name
,我想加入此表结果应该是
pid name modelnumber
1 ball a
答案 0 :(得分:0)
我目前做类似以下的事情:
SELECT
PD.pid,
PD.name,
PD.modelnumber
FROM (
SELECT
(
COALESCE(ctP.[RANK], -1)
+
COALESCE(ctPT.[RANK], -1)
) AS [RANK],
P.pid,
PT.name,
P.modelnumber
FROM Product AS P
INNER JOIN ProductTranslation AS PT
ON PT.pid = P.pid
OUTER APPLY (
SELECT TOP 1
ctP.[KEY],
ctP.[RANK]
FROM CONTAINSTABLE(
Product,
*,
@Query
) AS ctP
WHERE ctP.[KEY] = P.pid
)
OUTER APPLY (
SELECT TOP 1
ctPT.[KEY],
ctPT.[RANK]
FROM CONTAINSTABLE(
ProductTranslation,
*,
@Query
) AS ctPT
WHERE ctPT.[KEY] = P.pid
)
WHERE
(
ctP.[KEY] IS NOT NULL
OR
ctPT.[KEY] IS NOT NULL
)
) AS PD
ORDER BY PD.[RANK] DESC