Q

Moving column values from one table to another

I have two tables wherein I have to get a string of values from one column of one table and pump the retrieved information into a new column in the other table. How do I do this?

I have two tables wherein I have to get a string of values from one column of one table and pump the retrieved information into a new column in the other table. How do I do this?
If you just need to insert the data from one table into another, then you can use the INSERT..SELECT command similar to the following:
INSERT INTO new_table (columnA) SELECT columnB FROM old_table;
If you need to update a column in one table based on the values in another, then you will need to figure out which column maps rows from one table to the other. In my example below, I'll call this column the key_column. The UPDATE command can look like the following:
UPDATE new_table SET columnA = (SELECT columnB FROM old_table
         WHERE old_table.key_column = new_table.key_column);
This was first published in August 2006

Dig deeper on Oracle and SQL

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close