Assuming that all of these columns are in the same table:
update some_table
set field1=field1_spanish,
field2=field2_spanish
where field1_spanish is not null
and field2_spanish is not null;
If field1
and field2
are in table
and the *_spanish
columns are in table_spanish
, then...well, SQLite doesn't support a from
clause in an update
statement, so you'll have to do a correlated subquery. Assuming that table
has a primary key of id
that is referenced by table_spanish
, you can do:
update table a
set field1=(select s.field1_spanish
from table_spanish s
where field1_spanish is not null
and s.id=a.id),
field2=(select s.field2_spanish
from table_spanish s
where field2_spanish is not null
and s.id=a.id);
Or you can populate a staging table via a join and then delete the relevant entries from table
and insert the new data from the staging table (make sure to use a transaction for all of that!).
Hat tip to martin clayton for the second approach.