I have this MySQL query:
SELECT
id,
title
FROM song
WHERE text IS NOT NULL
AND title LIKE "%foo%"
ORDER BY title
What is a good way to adjust the ordering here so that those rows that starts with foo always comes before those that just contains it?
In other words, I want those LIKE "foo%" to come before those LIKE "%foo%", without duplicates.
You can try something like the following. I tried it out in SQL Fiddle and it works.