Reputation: 198
I have three tables as follows:
table 1 table 2 table 3
------- ------- -------
a a a
b c c
c f
d
e
f
I want to join this three tables into 1 which will result to the following:
result table
------------
a a a
b
c c c
d
e
f f
Noticed that the second and third col contains blank row if it does not have a match. How can I achieve this using oracle sql?
Upvotes: 0
Views: 2757
Reputation: 2277
SELECT *
FROM table1
LEFT OUTER JOIN table2 ON ( table1.name = table2.name )
LEFT OUTER JOIN table3 ON ( table1.name = table3.name )
Upvotes: 2
Reputation:
-- Enhance table
alter table table1 add (field2 /*e.g.*/ varchar2(10)
,field3 /*e.g.*/ varchar2(10) );
-- update rows roughly works like this. (I don't exactly know your column names, primary keys, etc)
update table1 o set o.field2 = (select i.field from table2
where o.field1 = i.field);
Upvotes: 0