Mysql自定义排序依据和字母排序依据: [英] Mysql custom order by and alphabetical order by:
本文介绍了Mysql自定义排序依据和字母排序依据:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下查询:
$query = "SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,'pdf','swf','img','web')";
选择并自定义我的mysql查询,它工作得很好,除了每个typeof中有多个文件,我现在想按字母顺序对它们进行排序,但仍保留其typeof顺序.有道理吗?
to select and customly order my mysql query, it works great except there are multiple files within each typeof and I now want to order them alphabetically yet retaining their typeof order. Make sense?
推荐答案
SELECT * FROM `$table[$a]`
ORDER BY
FIELD(typeof,'pdf','swf','img','web'), --first order by type
filename --then by filename
这篇关于Mysql自定义排序依据和字母排序依据:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文