我是 SQLite 新手。我使用此查询是为了从特定用户的列中提取所有行:
Cursor c = db.query(true, TABLE, COLUMN, USER + "= '" + user + "'", null, null, null, null, null);
这是一个表格示例:
|group-----ID|
|------------|
|one-------me|
|one------you|
|two-------me|
|one-------me|
因此,对用户“me”的查询会提取“一,二,一”。如何过滤结果以便仅获取一次值?比如“一,二”
谢谢
最佳答案
使用分组依据参数和适当的列名称:
Cursor c = db.query(true, TABLE, COLUMN, USER + "= '" + user + "'", null,
"group", null, null, null);
由于该方法中有九个参数,并且三个几乎相同的方法......
public Cursor query(boolean distinct,
String table,
String[] columns,
String selection,
String[] selectionArgs,
String groupBy, /* this one */
String having,
String orderBy,
String limit)
关于Android SQLite 数据库从查询中删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13810208/