onedumbcoder Posted July 3, 2009 Share Posted July 3, 2009 is there a shorter way of doing this: (title LIKE CONCAT('%', '$searchword', '%') OR description LIKE CONCAT('%','$searchword', '%')) also when a user enters a search string, do i want to explode that string or not? if yes do i explode it by white spaces? if yes what if they enter 9 words, wouldnt that mean I have to do 9 like statments for the title and 9 like statements for the description? Also how would I make it so that the results with the most word matches in it show up first? for example lets say we search "Learning Mysql" 3 results come back, first one only has matched learning second one only has matched mysql third one has matched both mysql and learning how would I make it so that the third match comes up first then the rest, the only solution I thought of was a union where I do an AND in the first query and an OR in the second, but when we are talking about multiple words, we will have a very large number of possible combination. so i must be missing something Link to comment https://forums.phpfreaks.com/topic/164709-questions-about-executing-a-word-search-query/ Share on other sites More sharing options...
fenway Posted July 4, 2009 Share Posted July 4, 2009 Well, you're "faking" a proper fulltext index, so there isn't much a choice. But you can roll-your-own rankings and weights. Link to comment https://forums.phpfreaks.com/topic/164709-questions-about-executing-a-word-search-query/#findComment-868635 Share on other sites More sharing options...
onedumbcoder Posted July 4, 2009 Author Share Posted July 4, 2009 so whats the proper way of doing it then? Link to comment https://forums.phpfreaks.com/topic/164709-questions-about-executing-a-word-search-query/#findComment-868657 Share on other sites More sharing options...
fenway Posted July 4, 2009 Share Posted July 4, 2009 You can look at FULLTEXT indexing, but that has all sorts of limitations. Link to comment https://forums.phpfreaks.com/topic/164709-questions-about-executing-a-word-search-query/#findComment-868944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.