Link to home
Start Free TrialLog in
Avatar of MrAgile
MrAgileFlag for Australia

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



            
BEGIN
			SET @SQL = @SQL + ' AND (c.[Keywords] LIKE ''%' + @Keyword + '%'')'
			END

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

the eventual approch is to use full-text index instead of a "simple" LIKE.

ASKER CERTIFIED SOLUTION
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so in your SP you pass keyword the way you are doing. in my example i used @str as a my custom keyword list.
Avatar of MrAgile

ASKER

The values are all in one column like word, another word, yet another word. Will the full text index be suitable?
Avatar of MrAgile

ASKER

hi adilkhan,

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.