sql - How to merge existing row with new data in SQLite? -


I have a database filled with simple note data, columns for title, due date, priority, and description There is also a _id The column primary key is int.

I already have a note in the table and there is a note with the remaining spaces. I have a set of data that will fill those all fields.

Is there a way that I can only write data to that field which is zero?

I can not overwrite existing data, but I would like to add data to the tap column.

I know the line id of the target line.

If I had a line ID of 5 in my target line, then I could do something like this:

  update set = 'some date', priority = ' 2 ', description =' some text 'WHERE _id = 5  

but it will overwrite all the data in that row, and I do not want to lose the data that is there. How can I change this statement to avoid writing non-empty areas?

Suppose you create

  table "T" One "," b "," c "); Enter "T" ("A", "C") values ​​(1, 3);  

then

  update t set = one focus (a, 9), b = coalesce (b, 10), c = coalesce (c, 11) ));  

Will update only the zero values, i.e. Only column B will be set to 10 A and C will be left alone because they are respected.

The meaning of the Colossus is to select the first item in the list which is not zero.


Comments