Php mysql按顺序排列,以单词开头,然后按字母顺序排列

Php mysql按顺序排列,以单词开头,然后按字母顺序排列,php,mysql,Php,Mysql,我正在尝试执行一个mysql查询,该查询将使用以“timberwood”开头的标题对我的结果进行排序,从第一个开始,然后按字母顺序开始。这可能吗?或者我需要用php重新组织它吗?这是我试图使用的代码,但它没有按我想要的方式排序 SELECT *, (case when `title` like "timberwood%" then substring(title,6) else title end) as testing FROM #__downloads_items WHERE state =

我正在尝试执行一个mysql查询,该查询将使用以“timberwood”开头的标题对我的结果进行排序,从第一个开始,然后按字母顺序开始。这可能吗?或者我需要用php重新组织它吗?这是我试图使用的代码,但它没有按我想要的方式排序

SELECT *, (case when `title` like "timberwood%" then substring(title,6) else title end) as testing FROM #__downloads_items WHERE state = 1 ORDER BY testing asc 
任何帮助都将不胜感激

这应该可以解决这个问题:

Order by case when title like 'timberwood%' then 0 else 1 end asc, title asc
“case-when”将为以“timberwood%”开头的任何内容提供0的值,然后为其他内容提供1的值。因为这是第一件要排序的事情,所以所有“timberwood%”结果都应该排在第一位