mike
mike

Reputation: 8141

MySQL fulltext search - Only results that contain all words

With the following query I get results that contain the words "International" AND "Shipping" and I also get results that contain "International" OR "Shipping". What can I do to ensure that the results contain both words and not just one of them?

Any help would be greatly appreciated, thanks!

SELECT client_company,client_description,client_keywords
FROM tb_clients
WHERE
MATCH (client_company,client_description,client_keywords)
AGAINST ('International Shipping') > 0
LIMIT 10

Upvotes: 14

Views: 7771

Answers (1)

Pekka
Pekka

Reputation: 449673

Add a + in front of every required word and use IN BOOLEAN MODE.

11.8.2. Boolean Full-Text Searches

In implementing this feature, MySQL uses what is sometimes referred to as implied Boolean logic, in which

 + stands for AND
 - stands for NOT
  [no operator] implies OR

Upvotes: 28

Related Questions