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?


@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

26 Answered Questions

[SOLVED] Finding duplicate values in a SQL table

  • 2010-04-07 18:17:29
  • Alex
  • 2199550 View
  • 1489 Score
  • 26 Answer
  • Tags:   sql duplicates

4 Answered Questions

[SOLVED] Inserting multiple rows in a single SQL query?

32 Answered Questions

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

7 Answered Questions

25 Answered Questions

37 Answered Questions

22 Answered Questions

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

17 Answered Questions


  • 2009-01-07 01:47:23
  • Mike Trader
  • 256168 View
  • 474 Score
  • 17 Answer
  • Tags:   sql sqlite upsert

4 Answered Questions

[SOLVED] SQL Server SELECT into existing table

4 Answered Questions

Sponsored Content