开发者

Return one instance of each different SQLite column

开发者 https://www.devze.com 2023-02-21 05:29 出处:网络
The query I am doing is: Cursor cursor = managedQuery(Formula.CONTENT_URI, new String[] { Formula._ID, Formula.CATAGORY }, null, null, null);

The query I am doing is:

Cursor cursor = managedQuery(Formula.CONTENT_URI, new String[] { Formula._ID, Formula.CATAGORY }, null, null, null);

The problem is that it returns:

Algebra
Algebra
Algebra
...
Geometry
Geometry
...

How can I query this so that it return just ONE of each different column:

Algebra
Geometry

UPDATE:

The query I am running is:

SELECT * FROM for开发者_JAVA百科mula


try

SELECT DISTINCT * from formula;

But it is better practice to list out the column names, instead of using the * just in case anything changes.

so it'll look like

SELECT DISTINCT column_name from formula;

But the key really is the DISTINCT keyword.

0

精彩评论

暂无评论...
验证码 换一张
取 消