EMPLOYEE BOSS
NATURAL JOIN
• select id,E_name,B_name from Employee
natural join Boss where
employee.E_name>'N';
• In the output, only matching record which had
a match in the matching column(id) and
E_name is greater than N is shown in the
output.
SELF JOIN
• select a.e_name,a.id,b.manager_id from
employee a, employee b where b.manager_id
= a.id;
• The table employee is seen as two different
tables i.e table a and table b by oracle. And
then, table a and b are joined together.
• Below is the output for the above query
CROSS JOIN
• select employee.e_name,boss.b_name from
employee cross join boss;
• A total of 16 rows are shown in
the output.
• Each Record of employee table
is joined with all the records
of the boss table.
INNER JOIN
• select employee.e_name,boss.b_name from
employee inner join boss on
employee.id=boss.id;
• Condition is given with the help of ‘on’ clause
in inner join.
• If id in employee table is equal to id in boss
table, then it is listed in the output.
LEFT OUTER JOIN
• select employee.e_name,boss.b_name from
employee left outer join boss on
employee.id=boss.id;
• All the records of employee table and
matching records of boss table are listed.
RIGHT OUTER JOIN
• select employee.e_name,boss.b_name from
employee right outer join boss on
employee.id=boss.id;
• All the rows of boss table and matching rows
of employee table are listed
FULL OUTER JOIN
• select employee.e_name,boss.b_name from
employee full outer join boss on
employee.id=boss.id;
• Both the tables are fully listed
UNDERSTANDING JOINS
SELF JOINS
Non equi joins
Cross Join
• When all the records of table 1 are combined
with al the records of table 2