Answer the question
In order to leave comments, you need to log in
How to make a mass update/insert in SQLite without nulling fields not specified in the query?
I ask the help of SQLite experts in solving the following problem :)
There is a table Table1. It has 4 columns: id (unique), doc, name, info:
For example, it contains the following values:
I need to do a mass update of the fields SPECIFIED in the request. I do it like this:
Everything would be fine, but only all fields not specified, in this case, are reset to zero. Result after the query:
As you can see, the info column has become null. Is there a way to make the update or insert work only for the specified fields? The variant with one request for each id is not suitable. Also, getting the values of unspecified columns beforehand will also fail, since all the data is pulled in from the outside.
Answer the question
In order to leave comments, you need to log in
UPDATE Table1 SET name = ‘newname1’ WHERE id = 1;
And so on...
And so you only insert (replace) lines, but do not update values.
For bulk modification in this particular example:
Finally, check out the sqlite3 marginal notes.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question