Title
#users-public
Emmett

Emmett

09/13/2022, 10:48 PM
Is it possible to insert into a table using a SELECT statement with subqueries? For example:
WITH a as (
SELECT * from prices where ts >= xyz
)
insert into 'table' select * from a
I am trying to do this, but I am getting this error:
table does not exist [table=insert]
Newskooler

Newskooler

09/13/2022, 10:58 PM
You should have the insert into at the top, then you should be fine I believe.
Andrey Pechkurov

Andrey Pechkurov

09/13/2022, 11:11 PM
WITH clause is not supported in INSERT, but otherwise you should be able to use subqueries. Just use the
INSERT INTO tab SELECT ...
syntax.
Emmett

Emmett

09/13/2022, 11:12 PM
Got it thank you @Newskooler & @Andrey Pechkurov