SQL Notes Part3
SQL Notes Part3
a) Joins are used to retrive the data two or more relatedtables or SQL JOIN clause is used to
combine rows from
2)outerjoin
3)self join
4) cross join
1)inner join: inner join returns only matcheching rows in both tables. Non matching rows are
eliminated.
2)outerjoin: Outer join returns all the rows of both tables whether it has matched or not. it is
devided into three types.
a) Left outer join: Left outer join display the all rows in left table and matched rows in right table.
b) Right outer join: Right outer join display the all rows in right table and matched rows in left
table.
syntax: select var1,var2 from table1 right join table2 on table1.matchedvar=
table2.matchedvar.
c) Full outer join:Full outer join returns all the rows from both tables whether it has been
matched or not.
syntax: select var1,var2 from table1 full outer join table2 on table1.matchedvar=
table2.matchedvar.
3)self join: join of a table to itself is called self join. In this join table appers twicein the form
clause and is followed by table
4) cross join:A cross join that produces Cartesian product of the tables that are involved in the
join. The size of a Cartesian product is the number of the rows in the first table
syntax: