Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
can any one tell me the use of outer join asn how we apply them in querry
Posted

 
Share this answer
 
Comments
Abhinav S 24-Jul-12 9:32am    
5. Good links.
Sandeep Mewara 24-Jul-12 9:38am    
Thanks Abhinav.
Using Outer Joins[^]
It 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.

Where to use outer joins?[^]
What is SQL OUTER JOIN[^]
 
Share this answer
 
Comments
Abhinav S 24-Jul-12 9:32am    
5! Good references.
Prasad_Kulkarni 25-Jul-12 0:08am    
:) Thank you Abhinav!
Outer Joins can primarily be considered to be of two types - left and right outer joins.

A left outer join is used when you want all rows in the first table and joined rows from the second table.

A right outer join is used when you want all rows in the second table and joined rows from the first table.

Lets say you have two tables

Table A
Id  Name
1   A
2   B
3   C


Table B
VB
Id  Name  Rank
1   B     1
2   D     2
3   E     3

If you use left outer on these tables by using a query like
select A.Name, B.Rank from table1 A left join table B on A.Name = B.Name

your output would be -
Name Rank
A      
B      2
C


Only the rank for B was returned, however rows for the first table were still returned.
 
Share this answer
 
Comments
Sandeep Mewara 24-Jul-12 9:38am    
My 5! Well explained.
Abhinav S 24-Jul-12 9:39am    
Thank you.
Prasad_Kulkarni 25-Jul-12 0:08am    
Well, now this is the best one +5!
Abhinav S 25-Jul-12 1:45am    
Thanks.
vanita khatnani 4-May-13 1:58am    
EXCELLENT EXPLANATION...
if oracle 6i means use + symbol
ex : select * from emp,dept
where emp_dept_id = dept_id(+)

if oracle 10g means use keyword outer join.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900