Results 1 to 20 of 194

Thread: Geeks - Tip of the Day

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Geeks - Tip of the Day

    Join Types - III

    Outer Join
    outer join extends the results of inner join. Along with inner join results it will also return non matched rows from the table with outer join operator(+). Missing values are filled with null.

    Left Outer Join
    It returns row that meets the join condition + rest of the rows from left table
    Code:
     
    Ex:- select b.dname, a.ename, a.job, a.sal 
         from   emp a , dept b 
         where  b.deptno = a.deptno(+); 
    Ansi Syntax 
         select b.dname, a.ename, a.job, a.sal 
         from   dept b left outer join emp a 
         on a.deptno = b.deptno;
    Right Outer Join
    It returns row that meets the join condition + rest of the records from table on the right side.
    Code:
     
    Ex:- select b.dname, a.ename, a.job, a.sal 
         from emp a , dept b 
         where a.deptno(+) = b.deptno; 
    Ansi Syntax 
    
        select b.dname, a.ename, a.job, a.sal 
        from   emp a right outer join dept b 
        on     a.deptno = b.deptno;
    Full Outer Join
    It returns rows that meet the join codition + rest of the records from both the tables

    Code:
     
    Ansi Syntax 
    select b.dname, a.ename, a.job, a.sal 
    from   emp a full outer join dept b 
    on     a.deptno = b.deptno;



  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Geeks - Tip of the Day

    JOIN TYPES - IV

    Anti Join
    It returns rows from first table for which there are no corresponding rows in the second table. Anti joins are written using NOT EXISTS or NOT IN.

    Code:
    Ex:-   SELECT a.dname 
           FROM   dept a
           WHERE  NOT EXISTS ( SELECT 1 FROM emp b WHERE b.deptno = a.deptno);
    Which is same as 
            SELECT dname
            FROM   dept 
            MINUS
            SELECT b.dname
            FROM   emp a, dept b
            WHERE  a.deptno = b.deptno;
    Semi Join
    It return rows from the first table for which one or more joins are found in the second table. It is written using IN or EXISTS.
    Code:
    Ex:- SELECT a.dname 
         FROM   dept a
         WHERE EXISTS ( SELECT 1 FROM emp b WHERE b.deptno = a.deptno);



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact