Post by DesignLocker » Fri Jun 27, 2014 2:05 am

Hi.

On my site I am searching the term "Red". I am presented with a number of results such as:

Red Felt Bag
Red Laptop Bag
etc...

But I also get results like:

Credit Card Cover
Credit Card Cover Leather
etc..

This is because the letters 'red' existing inside of the word 'credit'. How can I prevent this and simply search the whole word/term only?

Newbie

Posts

Joined
Sun Jun 15, 2014 5:54 am

Post by melbagnato » Sun Jun 29, 2014 7:25 pm

Hi DesignLocker,

You can use REGEXP and the [[:<:]] and [[:>:]] word-boundary markers. For example:

Code: Select all

SELECT * FROM table WHERE keywords REGEXP '[[:<:]]red[[:>:]]'
You'll just need to modify the search function being called to include this expression.

Hope this helps.

- Mel

http://online.enterpriseconsulting.com.au

Site with OpenCart extensions & code downloads, many new extensions coming soon!
Follow us on twitter for more updates

Image


User avatar
Active Member

Posts

Joined
Wed Jan 13, 2010 1:39 pm
Location - Melbourne
Who is online

Users browsing this forum: No registered users and 86 guests