jgr
jgr

Reputation: 2931

MySQL Full text search AND operator

Is it possible to use full test search in InnoDB engine with AND operator for natural language mode? I mean query like below but with all words as required:

SELECT *, MATCH (body)  AGAINST ('mysql database') AS score FROM post ORDER BY score DESC;

For this query i want return all records which match both words:'mysql' AND 'database'. I know i can use + and BOOLEAN mode, but it causes another problems like other operators which i want to ignore (*,-,"'..)

Upvotes: 0

Views: 629

Answers (1)

Barmar
Barmar

Reputation: 781004

Add a WHERE clause that tests for each word separately:

SELECT *, MATCH (body)  AGAINST ('mysql database') AS score 
FROM post 
WHERE MATCH(body) AGAINST ('mysql') AND MATCH(body) AGAINST('database')  
ORDER BY score DESC;

Upvotes: 1

Related Questions