i have table duplicate id record.i written query record same id.now want update record id such follows
create table student1 (`id` int,`status` int,`amount` int , `name` varchar(10), `date` varchar(55)) ; insert student1 (`id`,`status`,`amount`, `name`, `date`) values (1,0,4500, 'ram', '04/02/2012'), (2,0,2000, 'shyam', '05/09/2013'), (2,0,6500, 'radhe', '11/11/2014'), (2,0,8000, 'radheshyam', '15/11/2013'), (4,0,1500, 'ghanshyam', '08/11/2014') ; id status amount name date 1 0 4500 ram 04/02/2012 2 0 2000 shyam 05/09/2013 2 0 6500 radhe 11/11/2014 2 0 8000 radheshyam 15/11/2013 4 0 1500 ghanshyam 08/11/2014 sqlquery:
select * student1 id in (select id student1 group id having count(*)>1) expected result :
id status amount name date 2 0 2000 shyam 05/09/2013 2 0 6500 radhe 11/11/2014 2 0 8000 radheshyam 15/11/2013 now want update 2 records id's 21,211.so trying cursor count return 3.after getting count m moving position 2 change id how write query update current cursor position record.
i din't test it, going.
cursor.movetofirst(); while ( !cursor.isafterlast()) { // update whatever want here db.getwritabledatabase().update( //table_name, //values, //whereclause, //args ); cursor.movetonext() } get values cursor on each position , make updates. operation should done outside main thread. use asynctask.
but shouldn't create db records id duplication. add autoincrement statement @ table creation.
Comments
Post a Comment