How to use MySQL like with order by exact match first
You can do:
select *
from table t
where col like '%Ami%'
order by (col = 'Ami') desc, length(col);
SELECT *
FROM table t
WHERE col LIKE '%Ami%'
ORDER BY INSTR(col,'Ami') asc, col asc;
You can do:
select *
from table t
where col like '%Ami%'
order by (col = 'Ami') desc, length(col);
SELECT *
FROM table t
WHERE col LIKE '%Ami%'
ORDER BY INSTR(col,'Ami') asc, col asc;