How do I choose a prefix over a generic "similar" result?

So, let's say I have the following columns to be selected when I use them %un%

as search LIKE

:

fun
unlikely
mundane

      

But what I want is that the first prefix results are displayed first - so basically they will be returned in the following order:

unlikely
fun
mundan

      

Is there an easy way to do this in MySQL, or will I just have to change the array of results after I get them in PHP?

I was going to do this on the PHP side, although I'm not sure if there is a MySQL way to do this.

+3


source to share


1 answer


You add

order by left (column,2) = 'un' desc 

      



This will put them at the top

+3


source







All Articles