需求:按照指定字符串排序,
分析:运用 FIRLD 可以实现
问题:字段中有null 值,需要放到最后
// 在排序前加 rating is null 并且 在 FLELD 中加 IFNULL(rating,"")
SELECT *
FROM `dl_school`
ORDER BY rating is null,FIELD(rating,"A+","A","A-",IFNULL(rating,"")),sort DESC
需求:按照指定字符串排序,
分析:运用 FIRLD 可以实现
问题:字段中有null 值,需要放到最后
// 在排序前加 rating is null 并且 在 FLELD 中加 IFNULL(rating,"")
SELECT *
FROM `dl_school`
ORDER BY rating is null,FIELD(rating,"A+","A","A-",IFNULL(rating,"")),sort DESC