Reputation: 3045
I'm not getting any rows returned with the following, and I don't know why. Have I defined the fulltext index correctly?
CREATE TABLE `client_contact` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`first_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`last_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`email` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`phone` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
`company` int(11) DEFAULT NULL,
`billing_address` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
FULLTEXT KEY `client_search` (`first_name`,`last_name`,`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
INSERT INTO `client_contact` (`first_name`, `last_name`, `email`, `phone`, `company`, `billing_address`) VALUES
('John', 'Smith', '[email protected]', '123456', 1, '1 Any Street'),
('Mary', 'Smith', '[email protected]', '123456', 1, '1 Any Street');
SELECT cl.*
FROM client_contact cl
WHERE MATCH(cl.first_name, cl.last_name, cl.email) AGAINST ('Smith')
Upvotes: 5
Views: 188
Reputation: 522
This is because the keyword Smith
exists in all rows. MySQL manual says "Words that are present in 50% or more of the rows are considered common and do not match".
Upvotes: 8