By jumpman23


2018-05-16 15:30:09 8 Comments

I am currently trying to insert data into a Redshift table from multiple temporary tables that I have created.

Insert into schema.table1 (

with a as (
select t1.country_code, t1.country_name
from t1
)

select * from a
);

The error that I get on this statement says the following: Amazon Invalid operation: syntax error at or near "as";. What do I need to change in order to be able to insert data from a temp table?

2 comments

@Kiran 2018-05-16 17:07:14

I just tried this and it worked for me.

insert into tempt1 ( with a as (select a from tempt2) select * from a);

@mdem7 2018-05-16 17:04:13

Is it not possible to run the command like this if you have same table structures in both schema.table1 and t1

insert into schema.table1 
select t1.country_code, t1.country_name
from t1;

One other thing you might want to check is, in your SQL table1 is in 'schema' but t1 is referred without a schema so it's in public, make sure you don't have two t1s with different structures.

Related Questions

Sponsored Content

36 Answered Questions

27 Answered Questions

[SOLVED] How do I UPDATE from a SELECT in SQL Server?

16 Answered Questions

[SOLVED] SQLite - UPSERT *not* INSERT or REPLACE

  • 2009-01-07 01:47:23
  • Mike Trader
  • 235560 View
  • 443 Score
  • 16 Answer
  • Tags:   sql sqlite upsert

21 Answered Questions

[SOLVED] Insert into ... values ( SELECT ... FROM ... )

24 Answered Questions

2 Answered Questions

7 Answered Questions

[SOLVED] What are the options for storing hierarchical data in a relational database?

5 Answered Questions

[SOLVED] SQL Server SELECT into existing table

1 Answered Questions

Correlated-subquery in INSERT statement - PostgreSQL

4 Answered Questions

Sponsored Content