Table 1:
id name desc
------------------
1 a abc
2 b def
3 c adf
Table 2:
name desc
------------
x 123
y 345
How do I run an sql update query that can update Table 1 with Table 2's name and desc using the id of table 1 and rownum in table2? It's okay to assume that rownum in table2 is the same as id of table 1. So the end result I would get is
Table 1:
id name desc
------------------
1 x 123
2 y 345
3 c adf
Below are scripts for table creation and record insertion
create table table1 (
id number,
name varchar2(10),
desc_ varchar2(10)
);
create table table2 (
name varchar2(10),
desc_ varchar2(10)
);
insert into table1 values(1, 'a', 'abc');
insert into table1 values(2, 'b', 'def');
insert into table1 values(3, 'c', 'ghi');
insert into table2 values( 'x', '123');
insert into table2 values( 'y', '456');
Credits to "update one table with data from another"