Thread: Multiple table join

Multiple table join

From
"Louise Cofield"
Date:
<div class="Section1"><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Greetings, SQL gurus!</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">I am attempting to select fields Location and Item_Num from table A where A.Location = B.Location,
</span></font><pclass="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial">AND </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">select Item_Description from table C, where A.Item_Num = C.Item_Num.</span></font><p
class="MsoNormal"><fontface="Arial" size="2"><span style="font-size:10.0pt; 
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Any help would be appreciated.</span></font><p class="MsoNormal"><font face="Arial" size="2"><span
style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial">Louise</span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font><p class="MsoNormal"><font face="Arial" size="2"><span style="font-size:10.0pt;
font-family:Arial"> </span></font></div>

Re: Multiple table join

From
Bruno Wolff III
Date:
On Mon, Oct 06, 2003 at 10:26:59 -0600, Louise Cofield <lcofield@box-works.com> wrote:
> 
> I am attempting to select fields Location and Item_Num from table A
> where A.Location = B.Location, 
> 
> AND 
> 
> select Item_Description from table C, where A.Item_Num = C.Item_Num.

Just list all three tables in the from item list and include both
conditions in the where clause (connected by and).

If there is more to your problem than this, you should supply more details.


Re: Multiple table join

From
"Louise Cofield"
Date:
That was waaaaay too simple -- thank you!

-----Original Message-----
From: Bruno Wolff III [mailto:bruno@wolff.to] 
Sent: Monday, October 06, 2003 10:38 AM
To: Louise Cofield
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Multiple table join

On Mon, Oct 06, 2003 at 10:26:59 -0600, Louise Cofield <lcofield@box-works.com> wrote:
> 
> I am attempting to select fields Location and Item_Num from table A
> where A.Location = B.Location, 
> 
> AND 
> 
> select Item_Description from table C, where A.Item_Num = C.Item_Num.

Just list all three tables in the from item list and include both
conditions in the where clause (connected by and).

If there is more to your problem than this, you should supply more
details.



Re: Multiple table join

From
"Dan Langille"
Date:
On 6 Oct 2003 at 10:26, Louise Cofield wrote:

> I am attempting to select fields Location and Item_Num from table A
> where A.Location = B.Location, 
> 
> AND 
> 
> select Item_Description from table C, where A.Item_Num = C.Item_Num.

Try:

select Location, Item_Num
from table A, B, C
where A.Location = B.Location
and A.Item_Num = C.Item_Num
-- 
Dan Langille : http://www.langille.org/