Reputation: 687
I need to implement FULL-TEXT search in a mySQL InnoDB v5.6.20.
I added on two varchar(256) columns one after the other a full-text index after the table was created via
ALTER TABLE 'client' ADD FULLTEXT('company')
and
ALTER TABLE 'client' ADD FULLTEXT('country')
When I use one column to MATCH
against a keyword I get expected results.
SELECT * FROM client WHERE MATCH (company) AGAINST (:keyword)
When I use two column to MATCH
against a keyword I get no
result at all.
SELECT * FROM client WHERE MATCH (company, country) AGAINST (:keyword)
What do I do wrong ?
Upvotes: 1
Views: 433
Reputation: 522699
Putting multiple columns inside a MATCH
will use AND
, so if you want OR
(based on your comment) you can try the following:
SELECT *
FROM client
WHERE MATCH (company) AGAINST (:keyword) OR MATCH (country) AGAINST (:keyword)
Upvotes: 2