Solved

How to do two joins in one query?

Posted on 2006-06-23
5
801 Views
Last Modified: 2008-01-09
Hi

I would like to do a join with the follow 3 tables:

RequisitionHeader RH
JobHeader JH
PurchaseProcessHeade PPH

The joins:
-RH and JH on RH.field1 = PPH.field1
-RH and PPH on RH.field2 = PPH.field2

The current non-working syntax:

FROM
RequisitionHeader RH INNER JOIN JobHeader JH,
RequisitionHeader RH INNER JOIN  PurchaseProcessHeade PPH
ON RH.JobNumber = JH.JobNumber AND RH.PurchaseProcessNumbe = PPH.PurchaseProcessNumbe

Please help!!
0
Comment
Question by:minichicken
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 16967559
Hi minichicken,

 FROM
 RequisitionHeader RH INNER JOIN JobHeader JH,
 ON RH.JobNumber = JH.JobNumber
RequisitionHeader RH INNER JOIN  PurchaseProcessHeade PPH
ON RH.PurchaseProcessNumbe = PPH.PurchaseProcessNumbe


Tim Cottee
0
 
LVL 12

Author Comment

by:minichicken
ID: 16967602
Hi Tim

that didnt really work, i think there is a syntax error with the common in the wrong place.
and it also dont accect the RH been called twice.

thanks
0
 
LVL 1

Accepted Solution

by:
Krn25 earned 500 total points
ID: 16967657
Hi

Try

FROM
 RequisitionHeader RH INNER JOIN JobHeader JH
 ON RH.JobNumber = JH.JobNumber
 INNER JOIN  PurchaseProcessHeade PPH
ON RH.PurchaseProcessNumbe = PPH.PurchaseProcessNumbe

krn
0
 
LVL 12

Author Comment

by:minichicken
ID: 16967721
ok that works :)

thanks
0
 
LVL 3

Expert Comment

by:chhapia_chintak
ID: 16967735
HI

try this

Select <<entities required>> from
FROM  RequisitionHeader RH
JOIN JobHeader JH  ON RH.JobNumber = JH.JobNumber
JOIN  PurchaseProcessHeade PPH ON RH.PurchaseProcessNumbe = PPH.PurchaseProcessNumbe

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now