Solved

How to do two joins in one query?

Posted on 2006-06-23
5
804 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

895 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