开发者

Android rawQuery help

开发者 https://www.devze.com 2023-01-01 16:20 出处:网络
I was wondering how I could query my database of 1400 items and get only the DISTINCT types and row ids. Below is the actual sql that I want to run by my program crash开发者_StackOverflowes if I dont

I was wondering how I could query my database of 1400 items and get only the DISTINCT types and row ids. Below is the actual sql that I want to run by my program crash开发者_StackOverflowes if I dont return ids.

 return mDb.rawQuery("SELECT DISTINCT Type from the_foods",null);

Any ideas?


I figured it out. I had to use the group by ("Type"):

return mDb.query(true, DATABASE_TABLE, new String[] {KEY_TYPE,KEY_ROWID,KEY_NAME},null, null, "Type", null, null, null);
0

精彩评论

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

关注公众号