Reputation: 81
I Know how to use 'full text search MySQL'. What i want to know is how to search text for words . For exmaple :- We have three records in mysql as following
1.) This is a place for programmers .
2.) People visit places for travelling purposes.
3.) programmers visit this place site for coding purposes.
Now When A user searches for 'place for programmers'
Following should be the output
it should output rows that contain all words from the sentence in any order
1.)This is a place for programmers.
2.)programmers visit this place site for coding purposes.
Thank You For Helping .
Upvotes: 2
Views: 3184
Reputation: 31
Before using the full text search, index the columns
ALTER TABLE <table> ADD FULLTEXT(column);
Verify that it already in Full Text
SELECT
index_name, group_concat(column_name) as columns
FROM
information_Schema.STATISTICS
WHERE
table_schema = 'your_db_name'
AND table_name = 'table_name'
AND index_type = 'FULLTEXT'
GROUP BY
index_name;
Then use following SQL
SELECT *
FROM <table>
WHERE MATCH(<column>) AGAINST('+place +for +programmers' IN BOOLEAN MODE)
Upvotes: 3
Reputation: 109
MySQL has MATCH..AGAINST for full text searches. Try the following,
SELECT * FROM <table> WHERE MATCH(<column>) AGAINST('+place +for +programmers' IN BOOLEAN MODE)
The +'s basically mean AND (you could use - for OR)
https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html
Upvotes: 1