首頁 >後端開發 >php教程 >Mysql查询数据返回排序

Mysql查询数据返回排序

WBOY
WBOY原創
2016-06-06 20:10:031053瀏覽

例如有这样一条语句

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;

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn