Farhan
Farhan

Reputation: 1483

Mysql match, against is not returning proper results

I am trying this query:

SELECT * FROM `table_name` WHERE MATCH(`field_name`)
AGAINST('+san +city' IN BOOLEAN MODE)

I want to get all records that should contain san city, but the result is different. In result am getting all records that contain "city" like "Pearl City, Salt lake city etc". What I am doing wrong.

Upvotes: 0

Views: 277

Answers (1)

Bjoern
Bjoern

Reputation: 16304

Try adding the MATCH in your SELECT-part of your query to get a grip on how MySQL works here:

SELECT *, MATCH(field_name) AGAINST('+san +city' IN BOOLEAN MODE)
FROM table_name 
WHERE MATCH(field_name) AGAINST('+san +city' IN BOOLEAN MODE)

You will see the priority in this column.

Keep in mind that your results differ if you're using MyISAM and MySQL < 5.6 or InnoDB and MySQL => 5.6. Here's a good article about it.

Upvotes: 2

Related Questions