Solved

How to do two joins in one query?

Posted on 2006-06-23
5
809 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

763 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