我有3個表,全文搜索使用多個表中的SQL
tblBook(BookID, ISBN, Title, Summary)
tblAuthor(AuthorID, FullName)
tblBookAuthor(BookAuthorID, BookID, AuthorID)
tblBookAuthor
允許一本書有多個作者,一個作者可能已經寫了許多書。
我使用全文搜索來搜索一個詞排名基地:
SET @Word = 'FORMSOF(INFLECTIONAL, "' + @Word + '")'
SELECT
COALESCE(ISBNResults.[KEY], TitleResults.[KEY], SummaryResults.[KEY]) AS [KEY],
ISNULL(ISBNResults.Rank, 0) * 3 +
ISNULL(TitleResults.Rank, 0) * 2 +
ISNULL(SummaryResults.Rank, 0) AS Rank
FROM
CONTAINSTABLE(tblBook, ISBN, @Word, LANGUAGE 'English') AS ISBNResults
FULL OUTER JOIN
CONTAINSTABLE(tblBook, Title, @Word, LANGUAGE 'English') AS TitleResults
ON ISBNResults.[KEY] = TitleResults.[KEY]
FULL OUTER JOIN
CONTAINSTABLE(tblBook, Summary, @Word, LANGUAGE 'English') AS SummaryResults
ON ISBNResults.[KEY] = SummaryResults.[KEY]
上面的代碼工作正常,只是在尋找tblBook
表。但現在我想根據搜索到的關鍵字搜索表tblAuthor
。
你能幫我嗎?
鏈接已經死了 – 2013-05-22 12:58:23