Monday, August 22, 2016

SQL Right join


The Right join use for just come the whole table information  on the right side only the left table data come with the result of matching .If there no matching there come null value.
                                                                        
Customer Table                                
Customer ID
Name
Phone  Number
1
Erfan
01672
2
Enan
01822
3
Ali
01722
Order Table 
OrderID
Quantity
CustomerID
123
1
1
321
2
2
222
4
4











Query:                
SELECT Customer.Name,Order.OrderID                        
 From Customer
Right  Join Order 
on  Customer.CustomerID = Order.CustomerID


Result:
Name
OrderID
Erfan
123
Enan
321
Null
222

  

                                                                        




Right  table all data come but left side only matching data come . How we decide which table right ,this is simple when we write sql left side table name is left and right side is right .For decision you can think your hand direction also.

No comments:

Post a Comment