Page 4 - Grouping Records and Join in SQL
P. 4

Data from two tables can be extracted by equijoin (by applying condition on cartesian product table)
               or natural join.

               EQUI JOIN (join in which columns are compared for equality)

               Join is Cartesian Product of two tables
               Equi join returns data from two tables using equality operator
               1.      select ename, dname
                       from employee, department
                       where employee.deptno = department.deptno
               OR
                       select ename, dname
                       from employee E, department D
                       where E.deptno = D.deptno
               2.      select ename, dname
                       from employee E, department D
                       where E.deptno = D.deptno
                       and E.deptno = 20


               E and D are table alias, temporary names of tables till the execution of SQL command.






























               NATURAL  JOIN

               Natural Join is an implicit join clause based on the common columns in the two tables being joined.
               Common columns are columns that have the same name in both tables.
               This is a much riskier join as with this join the query attempts to use all columns with common
               names to create a join.


               Consider two tables T1 and T2
   1   2   3   4   5