3

My first table(t1) is a simple list of websites.

url

My second table(t2) has two columns

url, source

I would like to do something like this

insert into t2(url, source) where ((select * from t1), '1');

But I am getting an error that I have to many rows from my select * from t1. I understand why I am getting the error, but how should I do this query instead?

The reason why I am not editing t1 is that I have many different "t1"s that I would like to mark in my new master table as different with the sourceIDs.

2
  • Why do we even need t1? A one-column table doesn't seem to serve any purpose when you can do all of your lookups directly with t2? Commented Jul 20, 2013 at 16:21
  • 1
    T1 is actually a staging table that you need in amazon redshift. Table t2 is the master table, but if I were to insert my data into that table I would have to do it record by record. By using the staging table I can load an entire file into a table, and then use the query to add my data to the master table. Commented Jul 20, 2013 at 16:23

1 Answer 1

1

If you want to copy the values of the url column from table t1 into the url column of table t2 and at the same time fill the source column with the value '1' then you can do it like this

INSERT INTO t2(url, source) SELECT url, '1' FROM t1;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.