Avatar of RTKHOT
RTKHOT
Flag for India asked on

Better search feature

I have a search tool in my website that returns all items (database = sql server) that contain the search string.

Presently, if I type 'red shirts' into search, it returns all records that contain this string in the description field of the items

Now, i need to modify it.

If an item description contains "shirt - red", then also the above search string (red shirts) should return such items. In other words, my search result should return all items that contain one or more words that were entered in the search irrespective of their sequence (red shirt or shirt - red)

How should I modify my database query?
Microsoft SQL Server 2008ASP.NET

Avatar of undefined
Last Comment
Habib Pourfard

8/22/2022 - Mon
Habib Pourfard

You can use full text search, Full-text search is an optional component of the SQL Server Database Engine.

Example:
USE AdventureWorks2008R2;
GO
SELECT Name
FROM Production.Product
WHERE CONTAINS(Name, ' "Mountain" OR "Road" ')

Open in new window


Querying SQL Server Using Full-Text Search
RTKHOT

ASKER
So do i have to first split all the words in the search text box and use as above with the OR seperator?
ASKER CERTIFIED SOLUTION
Habib Pourfard

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck