>
>
>
> A SELECT in an UPSERT should always contain a WHERE clause. Like this:
>
>INSERT INTO t1(a) SELECT a FROM t2 WHERE true ON CONFLICT(A) DO NOTHING;
>
> Without the WHERE clause, the ON keyword tricks the parser into
> thinking it is processing an "ON" join constraint on the FROM
On 7/7/18, Paul van Helden wrote:
> Hi,
>
> I've used the new UPSERT with success with a complex SELECT, then got to
> scratch my head for a while on a much simpler query, so assuming this might
> be a bug:
>
> CREATE TABLE T2 (A INTEGER PRIMARY KEY);
> INSERT INTO T2 VALUES (1);
> CREATE TABLE
On 7 Jul 2018, at 3:07pm, Paul van Helden wrote:
> INSERT INTO T1 (A) SELECT A FROM T2 ON CONFLICT(A) DO NOTHING;
It's possible that many people miss this construction because SQLite has
INSERT OR IGNORE INTO T1 (A) SELECT A FROM T2;
Simon.
___
Hi,
I've used the new UPSERT with success with a complex SELECT, then got to
scratch my head for a while on a much simpler query, so assuming this might
be a bug:
CREATE TABLE T2 (A INTEGER PRIMARY KEY);
INSERT INTO T2 VALUES (1);
CREATE TABLE T1 (A INTEGER PRIMARY KEY);
INSERT INTO T1 VALUES
4 matches
Mail list logo