michael munson wrote: >I have two databases, one has many fields I need, the other only has one. Is >it possible to go through the second database, and update specific rows on the >first? > >DB1 has many rows, and DB2 has some. Every row in DB2 is in DB1 and they both >have the same value for the key row so they can be cross-referenced. What is >an easy way to merge DB2 into DB1? > > Michael,
This should do what you want. -- assumes create table t (id, a, b, c) in both databases -- replace values of c in table t of db1 -- with values of c from table t in db2 if they exist sqlite3 db1_file >attach 'db2_file' as db2; >begin transaction; >create temp table tt as select id, one.a, one.b, case when two.c isnull then one.c else two.c end from t as one left join db2.t as two using(id); >delete from t; >insert into t select * from tt; >commit transaction; >drop table tt; HTH Dennis Cote