My problem is that I've to write this
select * from contacts where id in (select cpk from mapping where gpk = 'MY-VARIABLE-HERE')
Query in Android but it fails when its run.
When I run this with static variable it works and provide data but when I try this with selections args it fails.
So far I'have tried these:
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});
Please help me... Thanks in advance...
I resolved this, i was passing the wrong value for variable.
Cursor cursor = myDataBase.rawQuery("select * from contacts where id in (select cpk from mapping where gpk = ?)", new String[]{grpName});
Was working correct.
Thanks All for help.. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With