How to merge existing row with new data in SQLite?
Posted
by CSharperWithJava
on Stack Overflow
See other posts from Stack Overflow
or by CSharperWithJava
Published on 2010-05-15T20:02:11Z
Indexed on
2010/05/15
20:14 UTC
Read the original article
Hit count: 202
I have a database full of simple note data, with columns for title, due date, priority, and details. There is also a _id column PRIMARY KEY int.
Say I have a note in the table already with some data filled and the rest null. I also have a set of data that will fill all those fields.
Is there a way that I can only write data to the fields that are NULL?
I can't overwrite existing data, but I'd like to add data to NULL columns.
I know the rowId of the target row.
If my target row had rowId of 5, I could do something like this:
UPDATE SET duedate='some date', priority='2', details='some text' WHERE _id=5
But that would overwrite all the data in that row, and I don't want to lose any data that might be there. How can I change this statement to avoid writing to non-null fields?
© Stack Overflow or respective owner