Forum Moderators: coopster

Message Too Old, No Replies

Is there a simpler way to do this without using LIKE?

Create a query that matches all, part, or an arbitrary part of a search term

         

HughMungus

5:34 am on Apr 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



term, that is.

For example: I have a database that has a bunch of product keywords in it like this:

red widgets, green widgets, big red widgets, small red widgets

What I'm trying to do is figure out a way that if someone types into my search box, "red widgets" that they get the result for "red widgets" AND the result for "small red widgets". But I also want to show search results if they type in "expensive widgets" such that "expensive red widgets" shows up, also.

Now, I know that I can take the search string and parse it into individual words and put the words in various orders, etc and then do a foreach to loop through this list to see if any category descriptors match any combination of words (including combinations of words that are shorter and/or longer as far as number of words than the original search query)...but is there a better way of doing this than that (particularly without using LIKE because LIKE is giving me too many results that are not targted enough)?

Thanks!

killroy

8:52 am on Apr 8, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could use RLIKE with a regular expression that allows exactly one extra word each side and/or inbetween?

SN

jadebox

2:27 pm on Apr 8, 2005 (gmt 0)

10+ Year Member




What I'm trying to do is figure out a way that if someone types into my search box, "red widgets" that they get the result for "red widgets" AND the result for "small red widgets". But I also want to show search results if they type in "expensive widgets" such that "expensive red widgets" shows up, also.

If you're using MySQL, you might consider using it's "Full-Text Search" functions:

[dev.mysql.com...]

-- Roger