SQLite 选择列的 DISTINCT 值而无需排序 [英] SQLite Select DISTINCT Values of a Column without Ordering
本文介绍了SQLite 选择列的 DISTINCT 值而无需排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以在不排序的情况下获取 SQLite 列中不同值的列表.
I would like to know whether its possible to get a list of distinct values in a SQLite Column without ordering them.
我尝试了以下查询.但它会自动将唯一文本按升序排序.
I tried following query. But it automatically orders the unique text into ascending order.
SELECT DISTINCT column FROM table;
SELECT DISTINCT column FROM table;
例如
列
Mathew
Mathew
John
John
John
Numbers
Numbers
<小时>
结果
John
Mathew
Numbers
但我不希望它被订购.想要它在 Mathew, John, Numbers 中
But I would like it not to be ordered. Would like it in Mathew, John, Numbers
谢谢.
推荐答案
您想要什么顺序?
如果你想按照第一次出现的顺序获取值,你可以这样做:
If you want to get the values in the order of first appearance you can do:
select distinct column
from table
order by min(rowid);
这篇关于SQLite 选择列的 DISTINCT 值而无需排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文