Page 111 - Computer Software Application TP - Volume 1
P. 111

COMPUTER SOFTWARE APPLICATION - CITS



















           3  Right Join – Retrieve all rows from the right table and the matching rows from the left table.
           SELECT * FROM employee
           RIGHT JOIN department ON employee.department id = department.department id;
















           4  Full Outer Join(Using UNION) - Retrieve all rows when there is a match in either the left or the right table.

           SELECT * FROM employee
           LEFT JOIN department ON employee.department id = department.department id
           UNION
           SELECT * FROM employee
           RIGHT JOIN department ON employee.department id = department.department id;























           5  Self Join - Perform a join on a table with itself.

           SELECT e1.employee id, e1.employee name, e2.employee name AS manager name
           FROM employee e1
           INNER JOIN employee e2 ON e1.department id = e2.department id AND e1.employee id != e2.employee id;







                                                           96
                               CITS : IT & ITES - Computer Software Application - Exercise 29                                                         CITS : IT & ITES - Computer Software Application - Exercise 29
   106   107   108   109   110   111   112   113   114   115   116