SQL Server - How to join tables

Leave a Comment
       Here I will explain you how to join the tables.SQL joins are used to combine data from two or more tables. There are many types of joins available in SQL. Some of joins and their examples are written.

teachers table is as follows :
                                    
details table is as follows :
                                    

Inner join
      The most important of the joins is the Inner join. Inner join returns all rows from both tables as long as there is match between the columns.
 Then we get following result :

Left join
        Left join returns all rows from the left table,even there are no matches in right table. When there is no match, the result is null in right side.
  Then we get following result :

Right join
        Right join returns all rows from the right table,even there are no matches in left table. When there is no match, the result is null in left side.
 Then we get following result :

Full join
        Full outer join combines the result of both left and right joins.The joined table will contain all records from both tables, and fill in NULL for missing matches on either side.
 Then we get following result :

0 comments:

Post a Comment