I have 2 tables. First one contains user input, just some sentences. Second table contains blocked words. Now I need a script which selects all records from table 1 which contains at least 1 record from table 2. I've tried with LIKE or IN but was not successfull. Any ideas?
Here is an example:
CREATE TABLE #Messages (UserInput VARCHAR(500)) CREATE TABLE #BlockedWords (BlockedWord VARCHAR(50)) INSERT INTO #Messages(UserInput) VALUES ('This is a test'),('This is another test'),('This is the 3rd test') INSERT INTO #BlockedWords (BlockedWord) VALUES ('something'),('word'),('another') SELECT * FROM #Messages ---> WHERE [UserInput] contains any word from #BlockedWords <---- DROP TABLE #Messages DROP TABLE #BlockedWords
The above example should return record "This is another Test" because it contains "another" from BlockedWords.
As you see, I need some help with WHERE [UserInput] contains any word from #BlockedWords. Is it possible to do something like this?