Ugly on so many levels but this may work...

SELECT t1.Loc_CD, t1.Loc_Name, t2.A_Number
FROM t1
left Join t2 on t1.Loc_CD=t2.Loc_CD
UNION
SELECT t2.loc_CD, null AS Loc_Name, t2.A_Number
FROM t2
WHERE t2.loc_CD NOT IN (SELECT DISTINCT Loc_CD FROM t1)



On 9/1/05, Gaulin, Mark <[EMAIL PROTECTED]> wrote:
> Hmm.... that is nasty
> 
> One solution would be to do a union of three selects, one selecting just
> the case of being in both tables, the next for those records in table 1
> only, the last for those records in table 2 only.  Kinda lame, but
> better than nothing.
> 
>        Mark
> 
> -----Original Message-----
> From: Ian Skinner [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 01, 2005 2:24 PM
> To: CF-Talk
> Subject: LEFT AND RIGHT OUTER JOIN?
> 
> I think I have solidly walked into the realm of "why are you trying to
> do this?"  So any suggestions on alternate ways to look at this problem
> are welcome.
> 
> Say I have two tables something like these:
> 
> TABLE ONE
> Loc_CD  Loc_Name
> ABC             This
> DEF             That
> DFE             The Other
> 
> TABLE TWO
> Loc_CD  A_Number
> DEF             123
> ALT             456
> 
> I need a combined table that would look like this.
> Loc_CD  Loc_Name        A_Number
> ABC             This
> DEF             That            123
> DFE             The Other
> ALT                             456
> 
> Please presume I did not create the base table and have little control
> over their structure and data.  But I need to somehow derive the
> combined table.
> 
> How would one do this, is there such a thing as a double/left&right
> join?
> 
> 
> --------------
> Ian Skinner
> Web Programmer
> BloodSource
> www.BloodSource.org
> Sacramento, CA
> 
> "C code. C code run. Run code run. Please!"
> - Cynthia Dunning
> 
> Confidentiality Notice:  This message including any attachments is for
> the sole use of the intended
> recipient(s) and may contain confidential and privileged information.
> Any unauthorized review, use, disclosure or distribution is prohibited.
> If you are not the intended recipient, please contact the sender and
> delete any copies of this message.
> 
> 
> 
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:217142
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to