I am trying to update one column of second table based on column of first table. I want to update column lid in record table with values of cid column of detail table based on rid (detail table) and crid (record table).
public String updateId() {
String selectQuery = "UPDATE record SET lid = (SELECT detail.cid FROM detail WHERE detail.rid = record.crid" ;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
return null;
}
Log says:
android.database.sqlite.SQLiteException: near "crid"
Activity - on button click, using below code to update table:
dh.updateId();
lid,cid,rid,crid, ... why don't you use meaningful column names? It's hard to follow the logic, otherwise. And in the future, you'll have problems in maintaining your own logic, even if today it appears clear to your eyes (and yours only).