Question

I have a table for food and hotels like

CREATE TABLE `food_master` (
  `id` int(6) unsigned NOT NULL auto_increment,
  `caption` varchar(255) default NULL,
  `category` varchar(10) default NULL,
  `subcategory` varchar(10) default NULL,
  `hotel` varchar(10) default NULL,
  `description` text,
  `status` varchar(10) default NULL,
  `created_date` date default NULL,
  `modified_date` date default NULL,
  `chosen_mark` varchar(10) default 'no',
  PRIMARY KEY  (`id`),
  FULLTEXT KEY `description` (`description`,`caption`)
) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=latin1

And I have data in it. I use full text indexing in this table. I use the query

SELECT * FROM food_master am 
WHERE MATCH(description, caption) AGAINST ('Chicken')

This query works fine when i have 2 'Chicken' in the field 'caption'. but when i put third one it doesnt return a row.

Was it helpful?

Solution

try with IN BOOLEAN MODE as

MySQL can perform boolean full-text searches using the IN BOOLEAN MODE modifier. With this modifier, certain characters have special meaning at the beginning or end of words in the search string.

SELECT * FROM food_master 
WHERE MATCH(description, caption) AGAINST ('Chicken' IN BOOLEAN MODE)

Demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top