Reputation: 131
my friends, i have an issue about sql statement, i want to update a row with specific
parameters, when it is about one variable it is ok, but now i need to specify two.
HERE the code :
public void insertMembre(long id,String rm_26ts, int a36, int a37_1, int a38_1_1,
int a38_1_2, int a37_2, int a38_2_1, int a38_2_2){
ContentValues values = new ContentValues();
values.put(col_VUE,a37_1);
values.put(col_Vue_un ,a38_1_1);
values.put(col_Vue_deux, a38_1_2);
db.update(Membres_de_Menage,values,col_N_Ordre+"="+rm_26ts +_idquest+"="+id, null);
}
i have error sql exception : unrecognized token
Upvotes: 1
Views: 233
Reputation: 4099
Try this
db.update(Membres_de_Menage, values, col_N_Ordre + " = ? AND " + _idquest + " = ?", new String[] {rm_26ts, id});
Upvotes: 1
Reputation: 3130
Try this::
When you are checking more than one parameter then use "AND" or "OR" clause to join two or more conditions.
db.update(Membres_de_Menage,values,col_N_Ordre+"='"+rm_26ts +"' AND " +_idquest+"="+id, null);
Hope it Helps!!
Upvotes: 1
Reputation: 13520
You should use
db.update(Membres_de_Menage,values,col_N_Ordre+"='"+rm_26ts+"' AND " +_idquest+"="+id, null);
instead of
db.update(Membres_de_Menage,values,col_N_Ordre+"="+rm_26ts +_idquest+"="+id, null);
Upvotes: 1