Geeks Talk

Prepare for your Next Interview




Outer Join Query Example

This is a discussion on Outer Join Query Example within the SQL forums, part of the Databases category; Can any body give me query example to Full Outer join? I know for left, right outer join but i need how to write a full outer join query?...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-04-2008
Junior Member
 
Join Date: Nov 2007
Location: Bangalore
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mailtos.ravi is on a distinguished road
Outer Join Query Example

Can any body give me query example to Full Outer join? I know for left, right outer join but i need how to write a full outer join query?
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-04-2008
Junior Member
 
Join Date: Feb 2008
Location: Edinburgh
Posts: 21
Thanks: 3
Thanked 2 Times in 2 Posts
su123 is on a distinguished road
Re: Outer Join Query Example

A full outer join retrieves all the records in the both tables,
for example on two tables using the ON clause. The full outer join can retrieve the records on both tables even if the data not equals the data on the other table. Example script:

select e.last_name, d.Department_id, d.department_name
from employees e full outerjoin departments d
on (e.department_id = d.department_id);
IF your having Oracle database in your System run this query as it is
Bye sudheer.
Reply With Quote
  #3 (permalink)  
Old 03-04-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: Outer Join Query Example

Quote:
Originally Posted by mailtos.ravi View Post
Can any body give me query example to Full Outer join? I know for left, right outer join but i need how to write a full outer join query?

Dear Ravi,
If you know how to write left and righ outer joins then writing full outer join is very simple. Just use the word full in place of left or right.

The only difference is
·Left Outer Join: Returns rows from both tables that satisfy the join condition, and the rest of rows from the first (left) table.
·Right Outer Join: Returns rows from both tables that satisfy the join condition, and the rest of rows from the second (right) table.
·Full Outer Join: Returns rows from both tables that satisfy the join condition, the rest of rows from the first (left) table, and the rest of rows from the second (right) table.

Regards
Krishna
Reply With Quote
  #4 (permalink)  
Old 03-05-2008
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,432
Thanks: 8
Thanked 126 Times in 113 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: Outer Join Query Example

just try this sample query

select * from emp full outer join dept using (deptno)
Reply With Quote
  #5 (permalink)  
Old 03-05-2008
Expert Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 447
Thanks: 20
Thanked 54 Times in 54 Posts
susarlasireesha is on a distinguished road
Re: Outer Join Query Example

Code:
select emp.ename,emp.empno,emp.deptno from emp full outer join dept on emp.deptno= dept.deptno
the full outer join returned unmatched results for both tables. Depending on the database unmatched records will be displayed with a blank or a null.
Quote:
Originally Posted by mailtos.ravi View Post
can any body give me query example to full outer join? i know for left, right outer join but i need how to write a full outer join query?
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
difference between Union All and full outer join bvani MY SQL 5 10-23-2008 05:29 PM
SQL Server outer join chitrab SQL Server 3 03-28-2008 04:51 AM
calculating the sum of a field in a query with join 3roses Oracle 2 09-05-2007 01:17 PM
Writing query with LEFT OUTER JOIN N SRIRAM K Data Warehousing 5 09-03-2007 06:08 AM
Join Query without using NOT IN subquery Geek_Guest SQL 1 03-07-2007 04:24 PM


All times are GMT -4. The time now is 10:29 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved