如何按ON,OFF,SOLD排序行 [英] How to sort rows by ON, OFF, SOLD

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

问题描述

我有以下3个值可以在数据库中连续显示- ON OFF SOLD (列 sort_it ).当我在 ORDER BY sort_it ASC 上设置排序子句时,我将在sort_in列 OF 中获得值,然后 ON 出售. 但是我需要顺序 ON OFF SOLD .

I have followings 3 values that could be in a row in database - ON, OFF, SOLD (column sort_it). When I set the sort clausule on ORDER BY sort_it ASC, so I will get the items with a value in the sort_in column OF, then ON and SOLD. But I need the sequence ON, OFF, SOLD.

以某种方式存在吗?我的意思是...编辑一种将数据保存到数据库中的方法将是一项艰巨的任务,所以我会在最后一刻这样做.

Exist any way to do it somehow? I mean... edit a way saving data into database will be demanding, so I would do this in the last moment.

推荐答案

是的,您可以使用以下自定义数据排序:

Yes you can use custom data sortings like this:

SELECT * FROM table ORDER BY FIELD(`sort_it`,'ON','OFF','SOLD'),`sort_it`

这篇关于如何按ON,OFF,SOLD排序行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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