[sqlite-dev] UPSERT syntax error

3 views
Skip to first unread message

David Butler

unread,
Mar 29, 2019, 11:17:39 AM3/29/19
to sqlit...@mailinglists.sqlite.org
Dev,

SQLite version 3.28.0 2019-03-29 13:17:50
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE t1(i INTEGER PRIMARY KEY,c);
sqlite> CREATE TABLE t2(i INTEGER PRIMARY KEY,c);
sqlite> INSERT INTO t1(i,c)VALUES(1,1);
sqlite> INSERT INTO t2(i,c)SELECT i,c FROM t1;
sqlite> INSERT INTO t2(i,c)SELECT i,c FROM t1 ON CONFLICT(i)DO UPDATE SET c=execluded.c; 
Error: near "DO": syntax error
sqlite> 

Richard Hipp

unread,
Mar 29, 2019, 11:30:24 AM3/29/19
to sqlit...@mailinglists.sqlite.org
Add a "WHERE true" clause to the SELECT statement, per the documentation.


--
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-dev mailing list
sqlit...@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-dev

G. David Butler

unread,
Mar 29, 2019, 12:21:07 PM3/29/19
to sqlit...@mailinglists.sqlite.org
Thanks for the poke to look harder for it. I found it in the INSERT document under 2. INSERT INTO table SELECT...; second paragraph.

A gentle suggestion, add something to the UPSERT document too?

David

Sent from my phone. Please excuse misspellings and terseness.

Richard Hipp

unread,
Mar 29, 2019, 12:25:15 PM3/29/19
to sqlit...@mailinglists.sqlite.org
On 3/29/19, G. David Butler <g...@dbsystems.com> wrote:
> Thanks for the poke to look harder for it. I found it in the INSERT document
> under 2. INSERT INTO table SELECT...; second paragraph.
>
> A gentle suggestion, add something to the UPSERT document too?

I was just thinking the same thing. I'll make a note.

Reply all
Reply to author
Forward
0 new messages