SQL JOINS SQL> select * from persons; P_ID LAST_NAME FIRST_NAME ADDRESS CITY --------- ----------- --------------- ------------- ----------1 Kondawar Kapil N-1 CIDCO Aurangabad 2 Sanadi Pravin N-3 CIDCO Aurangabad 3 Mandil Shashank Khadkeshwar Aurangabad SQL> select * from orders; O_ID ORDER_NUM P_ID --------- --------- --------1 1111 3 2 2222 3 3 3333 1 4 4444 1 5 5555 15
INNER JOIN SQL> select p.p_id,last_name,first_name,o_id,order_num from persons p,orders o where p.p_id=o.p_id; P_ID --------3 3 1 1
LAST_NAME --------------Mandil Mandil Kondawar Kondawar
FIRST_NAME O_ID ORDER_NUM ---------- --------- --------Shashank 1 1111 Shashank 2 2222 Kapil 3 3333 Kapil 4 4444
LEFT JOIN SQL> select p.p_id,last_name,first_name,o_id,order_num from persons p,orders o where p.p_id=o.p_id(+) P_ID --------1 1 2 3 3
LAST_NAME --------------Kondawar Kondawar Sanadi Mandil Mandil
FIRST_NAME O_ID ORDER_NUM ---------- --------- --------Kapil 3 3333 Kapil 4 4444 Pravin Shashank 1 1111 Shashank 2 2222
RIGHT JOIN SQL>select p.p_id,last_name,first_name,o_id,order_num from persons p,orders o where p.p_id(+)=o.p_id
P_ID LAST_NAME FIRST_NAME O_ID ORDER_NUM ------ --------------- ---------- --------- --------3 Mandil Shashank 1 1111 3 Mandil Shashank 2 2222 1 Kondawar Kapil 3 3333 1 Kondawar Kapil 4 4444 5 5555