gpt4 book ai didi

php - Mysql自定义排序依据和字母排序依据:

转载 作者:可可西里 更新时间:2023-11-01 06:57:59 26 4
gpt4 key购买 nike

我正在使用以下查询:

$query = "SELECT * FROM `$table[$a]` ORDER BY FIELD(typeof,'pdf','swf','img','web')";

选择和自定义排序我的 mysql 查询,它工作得很好,除了每个 typeof 中有多个文件,我现在想按字母顺序排列它们,但保留它们的 typeof 顺序。有道理吗?

最佳答案

SELECT * FROM `$table[$a]` 
ORDER BY
FIELD(typeof,'pdf','swf','img','web'), --first order by type
filename --then by filename

关于php - Mysql自定义排序依据和字母排序依据:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7024854/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com