MYSQL按文字顺序 [英] MYSQL order by text

查看:79
本文介绍了MYSQL按文字顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我知道如何按ID或数字进行排序

okay so I know how I can sort by id or number like

$getTicket = $sql->query("SELECT * FROM `ticket` 
                          WHERE `user`='$user->name' 
                          ORDER BY `id` DESC");

我在票证表中有状态",并且我有3件事:

I have Status in the ticket table, and in that I have 3 things:

1)已回答2)未回答3)完成

1) Answered 2) Unanswered 3) Done

我想用这种方式对其进行排序:

I want to sort it in this way:

1)未答复
2)已回答
3)完成

1) Unanswered
2) Answered
3) Done

有没有办法做到这一点?

is there a way to do this?

推荐答案

做简单的事情-

ORDER BY FIELD(Status, 'Unanswered', 'Answered', 'Done')

这篇关于MYSQL按文字顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆