How to get a cursor with distinct values only?

前端 未结 4 992
无人及你
无人及你 2020-12-21 04:45

I want to return a cursor only with distinct values of a column. The column \'Groups\' has more items but with only 2 values: 1,2,1,1,1,2,2,2,1

String[] FRO         


        
4条回答
  •  温柔的废话
    2020-12-21 05:22

    You can use below example query, as you have to give column name for distinct

    Cursor cursor = db.query(true, YOUR_TABLE_NAME, new String[] { COLUMN_NAME_1 ,COLUMN_NAME_2, COLUMN_NAME_3 }, null, null, COLUMN_NAME_2, null, null, null);
    

    COLUMN_NAME_2 - name of the column for distinct.

    remember to add GROUP BY column names

提交回复
热议问题