MrAgile
asked on
Multiple keyword searching - syntax help please
Hi There,
I am wanting to search multiple keywords that are split by a comma. At the moment I have a stored procedure that builds that dynamic sql and executes like (WHERE ( c.[ID] IS NOT NULL) AND (c.[field] LIKE '%puff daddy%')) AS tablename) but when I add multiple keywords I get (WHERE ( c.[ID] IS NOT NULL) AND (c.[field] LIKE '%puff daddy,biggie smalls%')) AS tablename) and no results even when the column that i'm searching has a least one of the keywords.
I was wondering what the best approach was? Thanks in advance for your answer
I am wanting to search multiple keywords that are split by a comma. At the moment I have a stored procedure that builds that dynamic sql and executes like (WHERE ( c.[ID] IS NOT NULL) AND (c.[field] LIKE '%puff daddy%')) AS tablename) but when I add multiple keywords I get (WHERE ( c.[ID] IS NOT NULL) AND (c.[field] LIKE '%puff daddy,biggie smalls%')) AS tablename) and no results even when the column that i'm searching has a least one of the keywords.
I was wondering what the best approach was? Thanks in advance for your answer
BEGIN
SET @SQL = @SQL + ' AND (c.[Keywords] LIKE ''%' + @Keyword + '%'')'
END
the eventual approch is to use full-text index instead of a "simple" LIKE.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
so in your SP you pass keyword the way you are doing. in my example i used @str as a my custom keyword list.
ASKER
The values are all in one column like word, another word, yet another word. Will the full text index be suitable?
ASKER
hi adilkhan,
I will give that a try. back in a few minutes.
I will give that a try. back in a few minutes.
my example above is designed to take care of values in one column but multiple ROWs.
let me know if you need help.
let me know if you need help.