Saturday, March 19, 2016

JOINS in SQL SERVER

Here we have two tables :
 



Now the most common join is :
INNER JOIN :


Now , INNER JOIN will check for matching order_id in both tables. Here it will give us 6 rows.


LEFT OUTER JOIN:



Here all records from Left Table will be shown and only matching rows from right table will be displayed. Now we will get 7 rows.


 RIGHT OUTER JOIN:

Here all records from Right Table will be shown and only matching rows from left table will be displayed. Now we will get 9 rows.

FULL OUTER JOIN:

 Here it will give matching records of both tables as well as those which do not match. Now here we get 10 records.


 CROSS JOIN:


Cross Join give Cartesian product of both tables. Now one table had 7 rows , another had 9 rows. So we 63 rows in output.










No comments:

Post a Comment