Avatar of Senior Systems Engineer
Senior Systems Engineer
Flag for Australia asked on

Join a Table where the two columns need to be linked to single column in joined table

Hi,

I have the situation where I need to join a table where two columns within this table need to be linked to
the same column in the other (join) table. I use the following script below but it seems this does not
retrive the result sets i wanted. Can someone please help?

SELECT  
  t1.[PaymentID],
  t1.[PaymentFrom],  t2.[Client Name],
  t1.[PaymentTo],  t2.[Client Name]
FROM [Payments] t1 INNER JOIN [ClientDetails] t2
ON t1.[PaymentFrom] = t2.[ClienId] AND t1.[PaymentTo] = t2.[ClientId]


Table [Payments]
  [OrderID]
  [PaymentID]
  [PaymentFrom]
  [PaymentTo]

Table [ClientDetails]
  [ClientID]
  [Client Name]
  [Contact]
Microsoft SQL Server 2008Microsoft SQL Server 2005

Avatar of undefined
Last Comment
Paul_Harris_Fusion

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Paul_Harris_Fusion

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Paul_Harris_Fusion

Hello - have you abandoned this question?    If so could you close it off in some way and let me know if my solution was successful.......
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes