IT Community - Software Programming, Web Development and Technical Support

Using FULL OUTER JOIN

This is a discussion on Using FULL OUTER JOIN within the Database Support forums, part of the Web Development category; Hi all, Can someone specify the situation at when to use FULL OUTER JOIN in a query?...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-03-2007, 02:14 PM
Murali Murali is offline
D-Web Master
 
Join Date: Feb 2007
Location: India-Chennai.
Posts: 386
Murali is on a distinguished road
Send a message via AIM to Murali
Default Using FULL OUTER JOIN

Hi all,

Can someone specify the situation at when to use FULL OUTER JOIN in a query?
__________________
-Murali..
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-06-2007, 03:09 AM
Venkat Venkat is offline
D-Web Master
 
Join Date: Mar 2007
Posts: 350
Venkat is on a distinguished road
Thumbs up Re: Using FULL OUTER JOIN

Hi,

A common situation where you need to "merge" the data from two tables, and rows may or may not exist in either table. For example, suppose we have budgets in one table and actuals in another and we wish to present them side by side. Many people would use a FULL OUTER JOIN to accomplish this, perhaps writing something like this:

SELECT
coalesce(a.company,b.company) as company,
coalesce(a.account, b.account) as account,
coalesce(a.year,b.year) as year,
coalesce(a.month, b.month) as month,
coalesce(a.amount,0) as Actual,
coalesce(b.amount,0) as Budget
FROM
Actuals a
FULL OUTER JOIN
Budgets b on
a.company = b.company and
a.account = b.account and
a.year = b.year and
a.month = b.month

The above FULL OUTER JOIN will effectively "merge" the two tables and allow you to see all actuals and budgets for every company/account/year/month, and it will show values from either table even if there is not a matching value in the other table.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Index Full Hard Disk llowlene_discuss_me Introductions 8 10-09-2008 08:50 PM
thanks, glad to join up stevorama Introductions 0 03-02-2008 10:02 AM
Limitation In Join prasath Database Support 1 09-14-2007 05:38 AM
Full duplex audio conversation in .NET kingmaker C# Programming 0 07-19-2007 10:44 PM
Full duplex audio conversation in .NET kingmaker C# Programming 0 07-18-2007 10:36 PM


All times are GMT -7. The time now is 05:35 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0