Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Basic JOIN question

user13117585Oct 24 2022

Hello everyone,
I have a quick question about JOINs. I know what is an inner join, an outer join but I was wondering if there is a JOIN that can do that:

Imagine the following tables:

CREATE TABLE foo (
 id number, 
 name varchar2(100)
);
CREATE TABLE bar (
 id varchar2(10), 
 name varchar2(100)
);

INSERT INTO foo(id, name) 
SELECT LEVEL, 'x' || level from dual connect by level < 10;

INSERT INTO bar(id, name) VALUES('a', 'aaa');
INSERT INTO bar(id, name) VALUES('b', 'bbb');
COMMIT;

And I want a JOIN between these two tables to have a result like that:



    FOO.ID  FOO.NAME   BAR.ID     BAR.NAME     
---------- ---------- ---------- ----------
         1 x1         a          aaa       
         2 x2         b          bbb       
         6 x6         a          aaa           
         7 x7         b          bbb           
         8 x8         a          aaa           
         4 x4         b          bbb           
         5 x5         a          aaa           
         3 x3         b          bbb           
         9 x9         a          aaa           


9 rows selected. 


In reality I don't know how many rows they are in my tables. I just want two tables to be combined. Any suggestion?
Regards,

This post has been answered by Frank Kulash on Oct 24 2022
Jump to Answer
Comments
Post Details
Added on Oct 24 2022
12 comments
467 views