Solved

How to do two joins in one query?

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running total between 2 sql tables in Sql 6 50
Format Output of Select Statement 2 37
SQL Server Pivot 5 39
Section based report in SSRS 14 27
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

739 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