Joins:
Joins are used to combine records from two or more tables.
For joins a common column must exist between two tables.
Joins will execute faster and the performance will also increase.
We have two types of joins
1.Inner Join
2.Outer Join
i.Right Join
ii.Left Join
iii.Full outer Join
1.Inner Join:
It writes the records that are matching in the both table.
2.Left outer Join
It will written all the records from the left table and matching records from the right table.
3.Right outer Join
It will written all the records from the Right table and matching records from the Left table.
4.Full outer Join
It will writes all the records from both the tables.If there is no match between the tables them it will return null values in the fields.
Suppliers Table:
Products Table
Customers Table
Order Table:
OrderItem Table
1.Inner Join:
It writes the records that are matching in the both table.
Syntax: select column_Names from table_1 inner join table_2 on table_1 column_name =table_2 column_name
Command:
Output:
2.Left outer Join
It will written all the records from the left table and matching records from the right table.
Syntax: select column_Names from table_1 left outer join table_2 on table_1 column_name=table_2 column_name
Command:
3.Right outer Join
It will written all the records from the Right table and matching records from the Left table.
Syntax: select column_Names from table_1 Right outer join table_2 on table_1 column_name=table_2 column_name
Command:
4.Full outer Join
It will writes all the records from both the tables.If there is no match between the tables them it will return null values in the fields.
Syntax: select column_Names from table_1 Full outer join table_2 on table_1 column_name=table_2 column_name
Command:
5.Self Join
Self join is used to join the table to itself.
Command
Joins are used to combine records from two or more tables.
For joins a common column must exist between two tables.
Joins will execute faster and the performance will also increase.
We have two types of joins
1.Inner Join
2.Outer Join
i.Right Join
ii.Left Join
iii.Full outer Join
1.Inner Join:
It writes the records that are matching in the both table.
2.Left outer Join
It will written all the records from the left table and matching records from the right table.
3.Right outer Join
It will written all the records from the Right table and matching records from the Left table.
4.Full outer Join
It will writes all the records from both the tables.If there is no match between the tables them it will return null values in the fields.
Suppliers Table:
Products Table
Customers Table
Order Table:
OrderItem Table
1.Inner Join:
It writes the records that are matching in the both table.
Syntax: select column_Names from table_1 inner join table_2 on table_1 column_name =table_2 column_name
Command:
Output:
2.Left outer Join
It will written all the records from the left table and matching records from the right table.
Syntax: select column_Names from table_1 left outer join table_2 on table_1 column_name=table_2 column_name
Command:
3.Right outer Join
It will written all the records from the Right table and matching records from the Left table.
Syntax: select column_Names from table_1 Right outer join table_2 on table_1 column_name=table_2 column_name
Command:
4.Full outer Join
It will writes all the records from both the tables.If there is no match between the tables them it will return null values in the fields.
Syntax: select column_Names from table_1 Full outer join table_2 on table_1 column_name=table_2 column_name
Command:
5.Self Join
Self join is used to join the table to itself.
Command