ORACLE JOINS

JOINS:

            Join is combine columns from two or more tables into a single result set.

Joins are two type 1) sql joins
                              2)ANSI Joins


ANSI joins:
      
        it introduced complete join syntax in the from clause.

joins are  
              equi joins
              nonequi joins
              self join
              cross join
              inner join
              outer join

Equi joins: 
   To join the two or more tables using equality condition.

example of equi join

sql)  select a.id,a.name
        from a,b
        where a.id=b.id;

Non equi joins:
     to join the two or more tables other than equal to condition. like <,>,<=,=>,=!

select e.ename,e.sal
from emp e
where e.deptno <=20
/

Self Join:

         Self join is a join in which a table  is joined with it self.

Inner Join:

        this will display all the records that have matched.

Cross Join or Cortesion Join:

        to join two or more tables with out any condition.

Right Outer Join:

        it will give left side matching rows and right side all rows.

Left Outer Join:

       it will give right side matching rows and left side all rows.

Full Outer Join:

      it will give both side matching and unmatching rows.


we have two take two tables like a and b.

SQL> select * from a;                                select * f rom b;

        ID  NAME                                             ID     NAME
----------  -----                                               -----       ----------
         1     a                                                     2             b
         2     b                                                     3             c
         5     e                                                     4             d


LEFT OUTER JOIN:

SQL> select id,a.name,b.name
           from a left join b
           using(id);

             ID      NAME  NAME
             ---       -----         -----
             2          b              b
             1          a
             5          e

RIGHT OUTER JOIN:

SQL> select id,a.name,b.name
           from a right join b
           using(id);

                 ID    NAME   NAME
              -------  -------      -----
                 2           b          b
                 3                       c
                 4                       d

INNER JOIN:

SQL> select id,a.name,b.name
          from a inner join b
          using (id);

        ID      NAME   NAME
        ----      --------  ----------
          2            b           b

FULL OUTER JOIN:

select a.id,a.name,b.name
from a full outer join b
on (a.id=b.id)
/

       ID         NAME  NAME
      -----       ---------  ----------
         2               b           b
                                       c
                                       d
         1              a
         5              e

CROSS JOIN:


SQL> SELECT A.ID,B.NAME,A.NAME
           FROM A,B;

        ID      NAME  NAME
----------     ---------   -----
         1         b              a
         1         c              a
         1         d              a
         2         b              b
         2         c             b
         2         d             b
         5         b             e
         5         c              e
         5         d             e

9 rows selected.


Comments

Lilian Wale said…
There are some natural remedies that can be used in the prevention and eliminate diabetes totally. However, the single most important aspect of a diabetes control plan is adopting a wholesome lifestyle Inner Peace, Nutritious and Healthy Diet, and Regular Physical Exercise. A state of inner peace and self-contentment is essential to enjoying a good physical health and overall well-being. The inner peace and self contentment is a just a state of mind.People with diabetes diseases often use complementary and alternative medicine. I diagnosed diabetes in 2010. Was at work feeling unusually tired and sleepy. I borrowed a cyclometer from a co-worker and tested at 760. Went immediately to my doctor and he gave me prescriptions like: Insulin ,Sulfonamides,Thiazolidinediones but Could not get the cure rather to reduce the pain but bring back the pain again. i found a woman testimony name Comfort online how Dr Akhigbe cure her HIV  and I also contacted the doctor and after I took his medication as instructed, I am now completely free from diabetes by doctor Akhigbe herbal medicine.So diabetes patients reading this testimony to contact his email     drrealakhigbe@gmail.com   or his Number   +2348142454860   He also use his herbal herbs to diseases like:SPIDER BITE, SCHIZOPHRENIA, LUPUS,EXTERNAL INFECTION, COMMON COLD, JOINT PAIN, EPILEPSY,STROKE,TUBERCULOSIS ,STOMACH DISEASE. ECZEMA, GOUT, PROGENITOR, EATING DISORDER, LOWER RESPIRATORY INFECTION,  DIABETICS,HERPES,HIV/AIDS, ;ALS,  CANCER , MENINGITIS,HEPATITIS A AND B,ASTHMA, HEART DISEASE, CHRONIC DISEASE. NAUSEA VOMITING OR DIARRHEA,KIDNEY DISEASE. HEARING  LOSSDr Akhigbe is a good man and he heal anybody that comes to him. here is email    drrealakhigbe@gmail.com    and his Number +2349010754824

Popular posts from this blog

PRAGMA SERIALLY_REUSABLE

COLLECTION METHODS

CURSOR PARAMETERS