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!

LEFT OUTER JOINS behaviour makes me confusion

JhilApr 1 2017 — edited Apr 2 2017

Hi,

I have two tables

1) emp

2) payroll

>> Emp table

SQL> select * from emp;

        ID NAME         PROJECT      EMAIL

---------- ------------ ------------ ---------------

         1 sam          pendaflex    sam@gmail.com

         2 rose         pendaflex    rose@gmail.com

         3 sandy        pendaflex    sandy@gmail.com

         4 smith        pendaflex    smith@gmail.com

         5 jeff         pendaflex    jeff@gmail.com

         6 madona       catapult     madona@gmal.com

         7 stevens      pendaflex    steve@gmail.com

         8 chitale      pendaflex    chitgmail.com

8 rows selected.

>> Payroll table

U1> select * from payroll;

       ID NAME             SALARY      BONUS

---------- ------------ ---------- ----------

         1 sam                5700       1200

         2 rose               6000       1200

         3 sandy              3500       2200

         4 smith              2000       1850

         5 jeff               4000       1900

         9 scott              5200       1400

6 rows selected.

LEFT OUTER JOINS

"Returns rows from both tables that satisfy the join condition , and the rest of rows  from the  first (left) table".

Please see following queries. Both are almost same bit changes in where condition.

As per above statement , 2nd query is behaving bit different. Anyone please clarify it

>> 1 Query

SQL> select * from emp, payroll where emp.id = payroll.id(+);

        ID NAME         PROJECT      EMAIL                   ID NAME             SALARY      BONUS

---------- ------------ ------------ --------------- ---------- ------------ ---------- ----------

         1 sam          pendaflex    sam@gmail.com            1 sam                5700       1200

         2 rose         pendaflex    rose@gmail.com           2 rose               6000       1200

         3 sandy        pendaflex    sandy@gmail.com          3 sandy              3500       2200

         4 smith        pendaflex    smith@gmail.com          4 smith              2000       1850

         5 jeff         pendaflex    jeff@gmail.com           5 jeff               4000       1900

         8 chitale      pendaflex    chitgmail.com

         6 madona       catapult     madona@gmal.com

         7 stevens      pendaflex    steve@gmail.com

8 rows relected.

>> 2nd query

>select * from  emp,payroll where payroll.id = emp.id (+);

        ID NAME         PROJECT      EMAIL                   ID NAME             SALARY      BONUS

---------- ------------ ------------ --------------- ---------- ------------ ---------- ----------

         1 sam          pendaflex    sam@gmail.com            1 sam                5700       1200

         2 rose         pendaflex    rose@gmail.com           2 rose               6000       1200

         3 sandy        pendaflex    sandy@gmail.com          3 sandy              3500       2200

         4 smith        pendaflex    smith@gmail.com          4 smith              2000       1850

         5 jeff         pendaflex    jeff@gmail.com           5 jeff               4000       1900

                                                              9 scott              5200       1400

6 rows selected.

Thanks in advance.

This post has been answered by Frank Kulash on Apr 1 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 30 2017
Added on Apr 1 2017
22 comments
1,464 views