android - Update entire column from another table -


i have 2 tables, table 1

table1

and table 2

table 2.

i trying copy column rawqty table 2 table 1, copies first row of table, duplicating same item in row.

i have tried 2 queries, both give same result. here code:

public void copyitemtoreset(){      sqlitedatabase db = mmpdbhelper.this.getwritabledatabase();      string sql1 = "update " + item_detail_table + " set " +itemdetail_rawqty + "= ( "  + " select " + item_refresh_rawqty + " " + item_refresh_table+") exists " +         "( select * " + item_refresh_table + " " +item_detail_table+"."+itemdetail_bomno + "="+item_refresh_table+ "." +item_refresh_bomno+")";         string sql2 = "update " + item_detail_table + " set " +itemdetail_finiqty + "= ( "  +" select " + item_refresh_finiqty + " " + item_refresh_table+")";         string sql3 = "update " + item_detail_table + " set " +itemdetail_qtyumused + "= ( "  +" select " + item_refresh_qtyumused + " " + item_refresh_table+")";      try {           log.i("sql1=", sql1);         log.i("sql2=", sql2);         log.i("sql3=", sql3);          db.execsql(sql1);         db.execsql(sql2);         db.execsql(sql3);     } catch (exception exe) {         exe.printstacktrace();         db.endtransaction();         log.e("insertion failed", "transaction failure when inserting itemdet data.");         this.closedatabase();         log.i("db closed", "database closed , copied successfully");         errcode = "err-db-06";         logfilecreator.appendlog(errcode + " : " + exe.getmessage());     } } 

the subquery must correlated subquery returns 1 value, different 1 each execution:

update itemdetail set rawqty = (select rawqty               itemrefresh               bomno = itemdetail.bomno                 , item  = itemdetail.item); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -