Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 A Join (I think)

Author  Topic 

mlawton40
Starting Member

15 Posts

Posted - 2007-04-18 : 06:38:14
Hi, I have the following 3 tables and columns:

Order Group
OrdGroup
Description

XRef_AR_OrderGroup
ARId
OrdGroup

AR
ARId
CustomerName

I am trying to pull from these tables the CustomerName and Description when an AR is in a Order Group (XRef_AR_OrderGroup).

Any help would be great!

Thanks, Mark

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-04-18 : 06:42:24
select t1.description, t3.customername
from order_group as t1 inner join xref_ar_ordergroup as t2 on t2.ordgroup = t1.ordgroup
inner join ar as t3 on t3.arid = t2.arid
where t2.ordgroup = <somevalue> or t2.arid = <somevalue>


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-04-18 : 06:43:29
Join OrderGroup <-> XRef_AR_OrderGroup on OrdGroup
Join XRef_AR_OrderGroup <-> AR on ARID

and you should be able to get desired output.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -