If I have a table on my DB called product_tags
with 2 fields: tag_id
and tag_name
Here is the schema:
CREATE TABLE `product_tags` (
`tag_id` int(11) NOT NULL auto_increment,
`tag_name` varchar(255) NOT NULL,
PRIMARY KEY (`tag_id`),
UNIQUE KEY `tag_name` (`tag_name`)
) ENGINE=MyISAM AUTO_INCREMENT=84 DEFAULT CHARSET=utf8
Say here some tags in it:
- yellow gold
- yellow diamond
- white gold
- rose gold
- band
- diamond
- blue diamond
- pink diamond
- black diamond
And I want to do a search on the string "yellow gold diamond band"
I only want to pull the following tags:
- yellow gold
- band
- diamond
Because only those tags are exactly in the string. yellow and diamond are both in the string but not together so the yellow diamond
tag should be ignored.
-Additionally if possible
If I did the search for "yellow gold blue diamond band"
I only want to pull the following tags:
- yellow gold
- band
- blue diamond
the diamond
tag would be ignored because the blue diamond
tag would be the match.
How can I do this?