0

Let me try to explain My case, I have two table and each of the table contains two fields that am interested in i.e act_num and identity. The first table has data for both fields but the second table has data for act_num and no data for identity. I am trying to write a query so that if the act_num in the second Table is equal to the act_num in the second table then the identity of the first table is imported into the respective row in the second table? What is the best way to do this? Must I use a cursor?

The tables are Oracle table 10g and am using toad for oracle for the sql. Please Help. SOmething like:

insert into table2 (identity) select identity from table1 
where act_num = select act_num from table2;

I do not need all the identity data from table1. I just need identity data for the act_num that are in both table1 and table2. Please help.

4

2 に答える 2

1

You could just update it based on the first table, maybe a solution would be:

update table2 set identity = (select 
    identity from table1 where act_num = table2.act_num);

This should be enough to update all lines from table2 with the identity of table1 where act_num is the same as found in table1.

于 2012-07-25T07:45:41.563 に答える
0
insert into table2 (identity) 
select identity from table1
where act_num in(select act_num from table2);
于 2012-07-25T07:44:11.123 に答える