Page 1 of 1

Search question - how to get specific

Posted: Fri Jan 17, 2003 12:50 pm
by JPlush76
I have a search script on my site now using LIKE with wildcards on either side. The problem is that if someone searches on "APHS" which is a type of film, anything with the word photogrAPHS comes up too.

Obviously because the pattern matches. However if I take off the wildcards it wont find it because its not the first word of the string.

Anyone have anything thoughts on how to go about that? So that if you search on APHS is searches the whole field to see if there is a word match?

thanks!

Posted: Fri Jan 17, 2003 1:26 pm
by Johnm
Is photographs the only word that is the problem? Is APHS allways uppercase, if so can you possibly check the case on any matches to verify that you have what you want.


Just some thoughts,
John M

Posted: Fri Jan 17, 2003 1:30 pm
by JPlush76
no its not the only word that is the problem it was just an example.

aphs is not always capital, just another example.

lets say I have a sentence "kodak films are great dude"

customer searches on "kodak film"

I'd want that product to come up because it contains kodak and film. I'd like to match words from start to end, having the end a wildcard IE LIKE $word%

the problem with that is if I use like its only checking the first word. :(

Posted: Fri Jan 17, 2003 2:08 pm
by volka
check out http://www.mysql.com/doc/en/Regexp.html
maybe you like it ;)
but of course it slows down the query

Posted: Fri Jan 17, 2003 2:10 pm
by JPlush76
lol yea I just found it volka.

it took me a while to find that stupid line :) thanks

products_name REGEXP '[[:<:]]$t' OR products_description REGEXP '[[:<:]]$t'