Unix Technical Forum

OUTER JOIN with multiple tables and a plus sign?

This is a discussion on OUTER JOIN with multiple tables and a plus sign? within the SQL Server forums, part of the Microsoft SQL Server category; --> I am trying to select specific columns from multiple tables based on a common identifier found in each table. ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 04:06 AM
TeleTech1212
 
Posts: n/a
Default OUTER JOIN with multiple tables and a plus sign?

I am trying to select specific columns from multiple tables based on a
common identifier found in each table.

For example, the three tables:

PUBACC_AC
PUBACC_AM
PUBACC_AN

each have a common column:

PUBACC_AC.unique_system_identifier
PUBACC_AM.unique_system_identifier
PUBACC_AN.unique_system_identifier


What I am trying to select, for example:

PUBACC_AC.name
PUBACC_AM.phone_number
PUBACC_AN.zip

where the TABLE.unique_system_identifier is common.



For example:

----------------------------------------------
PUBACC_AC
=========
unique_system_identifier name
1234 JONES

----------------------------------------------
PUBACC_AM
=========
unique_system_identifier phone_number
1234 555-1212

----------------------------------------------
PUBACC_AN
=========
unique_system_identifier zip
1234 90210


When I run my query, I would like to see the following returned as one
blob, rather than the separate tables:

-------------------------------------------------------------------
unique_system_identifier name phone_number zip
1234 JONES 555-1212 90210
-------------------------------------------------------------------


I think this is an OUTER JOIN? I see examples on the net using a plus
sign, with mention of Oracle. I'm not running Oracle...I am using
Microsoft SQL Server 2000.

Help, please?

P. S. Will this work with several tables? I actually have about 15
tables in this mess, but I tried to keep it simple (!??!) for the above
example.

Thanks in advance for your help!

NOTE: TO REPLY VIA E-MAIL, PLEASE REMOVE THE "DELETE_THIS" FROM MY E-MAIL
ADDRESS.

Who actually BUYS the cr@p that the spammers advertise, anyhow???!!!
(Rhetorical question only.)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 04:06 AM
Muzzy
 
Posts: n/a
Default Re: OUTER JOIN with multiple tables and a plus sign?

You do the following:

SELECT PUBACC_AC.Name + PUBACC_AM.Phone_number + PUBACC_AN.zip
FROM PUBACC_AC
INNER JOIN PUBACC_AM
ON PUBACC_AM.unique_col = PUBACC_AC.unique_col
INNER JOIN PUBACC_AN
ON PUBACC_AN.unique_col = PUBACC_AC.unique_col

That's it - you do inner join, if you want only those records, for which
unique_col value exists in all 3 tables.
Or, if you replace "INNER JOIN" with "FULL JOIN", which is the same as OUTER
JOIN in Oracle, you will get
as meny records as number of unique_col values.

Thats it!

Hope it helped,
Andrey aka Muzzy


"TeleTech1212" <tele_tech1212DELETE_THIS@yahoo.com> wrote in message
news:Xns9556E99BEE9B4teletech1212DELETETH@207.115. 63.158...
> I am trying to select specific columns from multiple tables based on a
> common identifier found in each table.
>
> For example, the three tables:
>
> PUBACC_AC
> PUBACC_AM
> PUBACC_AN
>
> each have a common column:
>
> PUBACC_AC.unique_system_identifier
> PUBACC_AM.unique_system_identifier
> PUBACC_AN.unique_system_identifier
>
>
> What I am trying to select, for example:
>
> PUBACC_AC.name
> PUBACC_AM.phone_number
> PUBACC_AN.zip
>
> where the TABLE.unique_system_identifier is common.
>
>
>
> For example:
>
> ----------------------------------------------
> PUBACC_AC
> =========
> unique_system_identifier name
> 1234 JONES
>
> ----------------------------------------------
> PUBACC_AM
> =========
> unique_system_identifier phone_number
> 1234 555-1212
>
> ----------------------------------------------
> PUBACC_AN
> =========
> unique_system_identifier zip
> 1234 90210
>
>
> When I run my query, I would like to see the following returned as one
> blob, rather than the separate tables:
>
> -------------------------------------------------------------------
> unique_system_identifier name phone_number zip
> 1234 JONES 555-1212 90210
> -------------------------------------------------------------------
>
>
> I think this is an OUTER JOIN? I see examples on the net using a plus
> sign, with mention of Oracle. I'm not running Oracle...I am using
> Microsoft SQL Server 2000.
>
> Help, please?
>
> P. S. Will this work with several tables? I actually have about 15
> tables in this mess, but I tried to keep it simple (!??!) for the above
> example.
>
> Thanks in advance for your help!
>
> NOTE: TO REPLY VIA E-MAIL, PLEASE REMOVE THE "DELETE_THIS" FROM MY E-MAIL
> ADDRESS.
>
> Who actually BUYS the cr@p that the spammers advertise, anyhow???!!!
> (Rhetorical question only.)



Digg this Post!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
Forum Jump


All times are GMT. The time now is 11:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com