How to pass two parameters in android sqlite
How to pass two parameters in android sqlite query statement?
My query looks like this, but I am getting error. If I use one where condition its working fine, but I want to use two condition.
开发者_如何学Pythondb.query(true, DB_TABLE, new String[] {KEY_ROWID,Source,
Dest}, DestStn + "=" + t ,Source + "=" +tt,null,
null, null, null, null);
you sould replace to "KEY_ROWID = ? AND Source = ?",
new String[] { t, tt }
Complete query:
db.query(DATABASE_TABLE, new String [] {KEY_ROWID, Source,Dest}, "Source = ? AND DestStn = ?",
new String[] { tt, t },
null,
null,
null);
you can use db.rawQuery(Your_Query);
i think in your case
String query = "Select * from "+DB_TABLE+ "Where" +DestStn + "=" + t +"and"+Source + "=" +tt
db.rawQuery(query);
Try using:
db.query(DB_TABLE, new String[] {KEY_ROWID,Source,Dest},
DestStn + "=" + t +" and "+Source + "=" +tt,null,
null, null, null, null);
精彩评论