troubleshooting Question

Search query matching words

Avatar of Peter Nordberg
Peter NordbergFlag for Sweden asked on
Microsoft SQL ServerSQL
20 Comments3 Solutions205 ViewsLast Modified:

I have a table looking like this:
customerID int,
Organisation nvarchar
index nvarchar

The data in the index column can look something like this:
trädgård; trädgårdsmaskin;trädgårdsresa,blommor;blombukett;

If a user now searches for 'trädgård' I would like the query only to give the result those result that exactly match that word. That is, I want to be able to parse and compare each word between the ; sign. The same true if the user searches for 'trädgård' and 'blommor' I want it to exaclty match the customer that have those two words in their index column.

If I do something like this it searches the word in the whole string:

SELECT * FROM customer WHERE index LIKE '%trädgård%'

Then I get all instances that contains that word and I don't want it to compare it to each word between the ;. Is that possible and if so how can I do it.

Thanks for help!

Join our community to see this answer!
Unlock 3 Answers and 20 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros