首页 > 后端开发 > php教程 > Mysql查询数据返回排序

Mysql查询数据返回排序

WBOY
发布: 2016-06-06 20:10:03
原创
1049 人浏览过

例如有这样一条语句

select uid from user where uid = 70 or uid =68 or uid = 69;

mysql返回的是

68
69
70

如何让mysql返回

70
68
69

这样的结果,就是按照where的条件先后来返回.

回复内容:

例如有这样一条语句

select uid from user where uid = 70 or uid =68 or uid = 69;

mysql返回的是

68
69
70

如何让mysql返回

70
68
69

这样的结果,就是按照where的条件先后来返回.

<code>SELECT id, name
FROM mytable
WHERE name IN ('B', 'A', 'D', 'E', 'C')
ORDER BY FIELD(name, 'B', 'A', 'D', 'E', 'C')</code>
登录后复制

网上随便找下就有了

<code class="php">select uid from user where uid in( 70 ,68 , 69) order by fine_in_set('uid','70,68,69');</code>
登录后复制

<code>select uid from user where uid = 70 or uid =68 or uid = 69 order by uid desc</code>
登录后复制

select uid from user where uid = 70 or uid =68 or uid = 69 order by uid desc;

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板