我是
Android的新手.
实际上,我想查询来自媒体提供商的数据与内容提供商&内容解析器.
实际上,我想查询来自媒体提供商的数据与内容提供商&内容解析器.
c = mContent.query(CONTENT_URI,projection,where,null,null);
我的问题是,如何使用GROUP BY子句从媒体提供程序查询数据如下:
select DISTINCT _id,count(_id),_data FROM aaa_table WHERE _data LIKE "A" OR _data LIKE "B" GROUP BY _id;
我试过设置投影,其中如下:
final String[] projection = new String[] { "_id","COUNT ("+ _id +")","_data" };
在哪里:
_data LIKE "A" OR _data LIKE "B"
但是,我找不到如何设置查询选项GROUP BY _id.
请帮我.
解决方法
where = "_data LIKE 'A' OR _data LIKE 'B'"; where += ") GROUP BY (_id"; // note the char ')' and '(',the ContentResover will completed for U c = mContent.query(CONTENT_URI,null);
referance page = http://zengyan2012.iteye.com/blog/1118963