I have a table of keywords and I want to query another table and return rows where a column contains at least one keyword.
Is it possible query like that using full text indexes?
If not is there a more efficient way than the one below – dynamic SQL perhaps?
SELECT
*
FROM
dbo.Notes AS NotesContainingKeyword
WHERE
EXISTS
(
SELECT
*
FROM
dbo.Notes
CROSS JOIN dbo.Keywords
WHERE
Notes.Note LIKE '%' + Keywords.Word '%'
AND Notes.Id = NotesContainingKeyword.Id
)
Best Answer
Concatenating the keywords with an
OR(|)
separator into a variable appears to work.