Skip to content
Advertisement

Sqlite copy data from temp table to another with conflict

i have db sqlite with main table and temp table. I want to import data from text file and then i want to insert data from temp table to main table.

When i am trying run this query then sqlite throw me this error.

Query 1 ERROR: near “DO”: syntax error

Is possible insert data from another table with conflicts?

Advertisement

Answer

The select statement needs a where clause:

This pitfall is documented as parsing ambiguity (emphasis mine):

When the INSERT statement to which the UPSERT is attached takes its values from a SELECT statement, there is a potential parsing ambiguity. The parser might not be able to tell if the ON keyword is introducing the UPSERT or if it is the ON clause of a join. To work around this, the SELECT statement should always include a WHERE clause, even if that WHERE clause is just WHERE true.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement