views:

337

answers:

1

I have a list of keywords (strings) in which I need to identify any matches with a blacklist of keywords (strings in a separate table)

Any keyword/blacklist matches will be flagged in a bit field: Keyword.IsBlacklisted.

Is there an easy way to accomplish this in SQL?

The matches might be partial (i.e. blacklist = 'sex' keyword = 'sex toy')

SOLUTION - Thanks Daniel Spiewak

 SELECT Keyword.Keyword FROM Keyword CROSS JOIN BlackList
 WHERE (Keyword.Keyword 
 LIKE { fn CONCAT({ fn CONCAT('%', BlackList.Keyword) }, '%') })
A: 
SELECT keyword FROM words JOIN blacklist 
               WHERE keyword LIKE CONCAT(CONCAT('%', word), '%')

Assuming that the words are in the keyword field of the words table and the blacklist contains its words in the word field. This will be anything but efficient, but I think it's the best you can do from a theoretical standpoint.

Daniel Spiewak
Got to be better than pulling the information out and programmically manipulating the data
Harry
SELECT Keyword.KeywordNameFROM Keyword CROSS JOIN BlackListWHERE (Keyword.KeywordName LIKE { fn CONCAT({ fn CONCAT('%', BlackList.BlackList) }, '%') })
Harry
The above MSSQL works a treat! thanks
Harry