MySQL order by “best match”
I have a table that contains words and an input field to search that table using a live search. Currently, I use the following query to search the table: SELECT word FROM words WHERE word LIKE '%searchstring%' ORDER BY word ASC Is there a way to order the results so that the ones where the string is found at the beginning of the word come first and those where the string appears later in the word come last? An example: searching for ' hab ' currently returns a lphabet h abit r ehab but I'd like it this way: hab it (first because 'hab' is the beginning) alp hab et (second because 'hab' is in