Hi friends
Thank you.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 23, 2012, 5:06 PM EDT
Please visit this web url for more examples,
http://msdn.microsoft.com/en-us/library/ms187518.aspx
http://www.sqlteam.com/article/writing-outer-joins-in-t-sql
http://www.mssqltips.com/sqlservertip/1667/sql-server-join-example/
MuthuMari MRank #5,738 · 288 reputationPosted Apr 23, 2012, 7:33 PM EDT
Outer joins return all rows from at least one of the tables or views mentioned in the FROM clause, as long as those rows meet any WHERE or HAVING search conditions.
All rows are retrieved from the left table referenced with a left outer join,
and all rows from the right table referenced in a right outer join.
All rows from both tables are returned in a full outer join
pls refer this url for sample queries :
http://msdn.microsoft.com/en-us/library/aa213228%28v=sql.80%29.aspx
thanks.
If this post is useful then mark it as "Accepted Answer"
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 23, 2012, 7:55 PM EDT
Please refer
http://dotnetslackers.com/articles/sql/SQL-SERVER-JOINs.aspx
it very good article on same.
hope this help.
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 23, 2012, 8:03 PM EDT
SQL LEFT JOIN Keyword
The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2).
SQL LEFT JOIN Syntax
FROM table_name1
LEFT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
PS: In some databases LEFT JOIN is called LEFT OUTER JOIN.
SQL LEFT JOIN Example
The "Persons" table:
The "Orders" table:
Now we want to list all the persons and their orders - if any, from the tables above.
We use the following SELECT statement:
FROM Persons
LEFT JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
The result-set will look like this:
The LEFT JOIN keyword returns all the rows from the left table (Persons), even if there are no matches in the right table (Orders).
SQL RIGHT JOIN Keyword
The RIGHT JOIN keyword returns all the rows from the right table (table_name2), even if there are no matches in the left table (table_name1).
SQL RIGHT JOIN Syntax
FROM table_name1
RIGHT JOIN table_name2
ON table_name1.column_name=table_name2.column_name
PS: In some databases RIGHT JOIN is called RIGHT OUTER JOIN.
SQL RIGHT JOIN Example
The "Persons" table:
The "Orders" table:
Now we want to list all the orders with containing persons - if any, from the tables above.
We use the following SELECT statement:
FROM Persons
RIGHT JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
The result-set will look like this:
The RIGHT JOIN keyword returns all the rows from the right table (Orders), even if there are no matches in the left table (Persons).
SQL FULL JOIN Keyword
The FULL JOIN keyword return rows when there is a match in one of the tables.
SQL FULL JOIN Syntax
FROM table_name1
FULL JOIN table_name2
ON table_name1.column_name=table_name2.column_name
SQL FULL JOIN Example
The "Persons" table:
The "Orders" table:
Now we want to list all the persons and their orders, and all the orders with their persons.
We use the following SELECT statement:
FROM Persons
FULL JOIN Orders
ON Persons.P_Id=Orders.P_Id
ORDER BY Persons.LastName
The result-set will look like this:
The FULL JOIN keyword returns all the rows from the left table (Persons), and all the rows from the right table (Orders). If there are rows in "Persons" that do not have matches in "Orders", or if there are rows in "Orders" that do not have matches in "Persons", those rows will be listed as well.
Please refer the below links
http://www.w3schools.com/sql/sql_join_left.asp
http://www.w3schools.com/sql/sql_join_right.asp
http://www.w3schools.com/sql/sql_join_full.asp
Thanks