Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Get relevant results first MySQL/PHP?
OK, so I have decided to make a little search where you can find what words you can find in a string with random placed characters. An example on the query I use is:
"SELECT * FROM 'words' WHERE 'word' LIKE '%a%', 'word' LIKE '%v%', 'word' LIKE '%c%', 'word' LIKE '%b%';"(Mine is just dynamic)
In the DB I have a column witch contains the word "abc" and I want it to show up first. So basically I want the results witch is the most relevant on the top and wondered if this was possible within the query. Or do I have to get the whole database then sort it out in PHP.
I have about +3000 results and it shows with that query every single with those characters witch is many. Can I put a "LIMIT 0, 20" on the query if I want the relevancy?
Hope someone can help me out here :-) If you dint understand a part tell me and I will explain more. Or you need more info.
-Adrian B. Hoffsten
1 Answer
- GodLv 77 years agoFavorite Answer
Your best bet is to create a function that returns the "match level" between your array of characters and a db record and sort by the match level.
Ex calculateMatch("fantastic","aastnuz") will return 5