Rumah > pembangunan bahagian belakang > tutorial php > Mysql查询数据返回排序

Mysql查询数据返回排序

WBOY
Lepaskan: 2016-06-06 20:10:03
asal
1049 orang telah melayarinya

例如有这样一条语句

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>
Salin selepas log masuk

网上随便找下就有了

<code class="php">select uid from user where uid in( 70 ,68 , 69) order by fine_in_set('uid','70,68,69');</code>
Salin selepas log masuk

<code>select uid from user where uid = 70 or uid =68 or uid = 69 order by uid desc</code>
Salin selepas log masuk

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

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan