I was digging around, and I'm not an expert on SQL, but after replacing characters that don't match, I thought of order strings of length char.
Something like: SELECT * FROM your_table ORDER BY LENGTH(REGEXP_REPLACE(title, '[^abcdefg]', ''));
2 problems. It does not match the most various characters found. Thus, aaaa will have higher value than abc. And I think you mean that you want abc to be more valuable. The second problem, probably the biggest one, mySQL does not support this regex. And not sure what is doing something. But I found this article: https://launchpad.net/mysql-udf-regexp
Although I think that there should be something much simpler and something that actually works out of the box, this answer may just prompt someone to think out of the box.
There may also be a solution with a lot of connections, but this is most likely slower than selecting everything and sorting it in php (or similar)
RenΓ©
source share