sqlite3 - Remove duplicate entries in a single row -


i have sqlite table shown below

 name  |        telnum0 |    telnum1 |    telnum2 |    telnum3 john  |        1234    |    1234    |     1234   |    1234 

now want update sqlite database db looks below:

 name  |        telnum0 |    telnum1 |    telnum2 |    telnum3 john  |        1234    |           |                   |     

this database not normalized; should have separate table numbers, 1:n relationship original table.

anyway, remove duplicates, have compare column values previous columns:

update insertthesecrettablenamehere set telnum1 = null telnum0 = telnum1;  update insertthesecrettablenamehere set telnum2 = null telnum0 = telnum2    or telnum1 = telnum2;  update insertthesecrettablenamehere set telnum3 = null telnum0 = telnum3    or telnum2 = telnum3    or telnum1 = telnum3; 

Comments