Possible Duplicate:
right join versus left join
is there any need of RIGHT join, bacause we can achieve the same result using LEFT join by just altering the table name
i have two tables Persons and Orders
P_Id LastName FirstName Address City
1 Hansen Ola Timoteivn 10 Sandnes
2 Svendson Tove Borgvn 23 Sandnes
3 Pettersen Kari Storgt 20 Stavanger
and
O_Id OrderNo P_Id
1 77895 3
2 44678 3
3 22456 1
4 24562 1
5 34764 15
and i have a query for left join as:
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Persons
LEFT JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
and with right join:
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo
FROM Orders
RIGHT JOIN Persons
ON Orders.P_Id=Persons.P_Id
ORDER BY Persons.LastName
both gives the same result.