I’m trying to search for people based on their skills by using different keywords. However, whenever I try to search, the results are narrowed down to match the exact keywords.
Example:
table for users:
ID Name Skills
1 Joe Smith Cooking Dancing Painting
2 John Williams Drawing Fishing
3 Beth Gray Cooking Swimming
4 Martin Torres Dancing Repairing CPR
5 Alice Lee Cooking Drawing Welding
If you search using the word “Cooking”, it will return 3 results which are 1,3 and 5 which is okay. However if you search using “Cooking Drawing”, it will only return 1 result which is 5 who has both Cooking and Drawing. What I am trying to achieve is for it to return ALL the people who have at least 1 of the skills in the keywords, in this case, 1,2,3 and 5.
Thanks.
You should use Mysql
Fulltextsearch feature.Here is query you can use in your code with full-text:
Note : You should apply
fulltextindexon columns in which you want to search.You can make query with
likewith combination ofANDORConditions :OR