我的问题是我必须写这个
select * from contacts where id in (select cpk from mapping where gpk = 'MY-VARIABLE-HERE')
在 Android 中查询,但运行时失败。
当我使用静态变量运行它时,它可以工作并提供数据,但是当我尝试使用选择参数时它会失败。
到目前为止,我已经尝试过这些:
1) Cursor cursor = myDataBase.rawQuery("select * from contacts where id in (select cpk from mapping where gpk = "+"'"+"?"+"'"+")", new String[]{grpName});
2) Cursor cursor = myDataBase.query(TABLE_CONTACTS, null, "id in", new String[]{"(select cpk from mapping where gpk = '"+grpName+"')"}, null, null, null);
3) Cursor cursor = myDataBase.rawQuery("select * from contacts where id in (select cpk from mapping where gpk = ?)", new String[]{grpName});
请帮助我...提前谢谢...