I am trying to run a simple Update query on a certain set of rows in my sqlite db. It works, but it NULLs out all the other rows. Here is the query:
update table1 set col5 =(select col5 from table2 where table2.id = table1.id)
I know this is super easy, but I can’t figure out what is going on. Can’t I only update certain rows, and leave the rest alone?
You are using the same columns you are updating to relate the two tables. You should use a primary or secondary key to relate the two tables.
See this very similar question and its answer: SQL update from one Table to another based on a ID match