Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6799957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:54:39+00:00 2026-05-26T18:54:39+00:00

Having a problem combining 2 JOINS. Both statements below work. I have also included

  • 0

Having a problem combining 2 JOINS. Both statements below work. I have also included the relevant fields in the 2 DBs. My question is:
1) How do I combine the 2 statements into 1 statement?
2) How do I reference the rows in my php to distinguish if the result was from the mmpreID JOIN or the mmparID JOIN?

Thanks

DB: matchmaker
mmpreID
mmparID

DB: users
uID
ufname
ulname

SELECT matchmaker.mmpreID, matchmaker.mmparID, users.uID, users.ufname, users.ulname 
FROM matchmaker 
LEFT JOIN users ON matchmaker.mmparID = users.uID

SELECT matchmaker.mmpreID, matchmaker.mmparID, users.uID, users.ufname, users.ulname 
FROM matchmaker 
LEFT JOIN users ON matchmaker.mmpreID = users.uID
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:54:40+00:00Added an answer on May 26, 2026 at 6:54 pm
    SELECT m.mmpreID, m.mmparID, u.uID, u.ufname, u.ulname,
        case 
            when m.mmparID = u.uID then 'mmparID'
            when m.mmpreID = u.uID then 'mmpreID'
            else null 
        end as Source
    FROM matchmaker m
    LEFT JOIN users u ON m.mmparID = u.uID or m.mmpreID = u.uID 
    

    Update:

    SELECT m.mmpreID, m.mmparID,
        upar.uID as upar_UID, 
        upar.ufname as upar_UFNAME, 
        upar.ulname as upar_ULNAME,
        upre.uID as upre_UID, 
        upre.ufname as upre_UFNAME, 
        upre.ulname as upre_ULNAME
    FROM matchmaker m
    LEFT JOIN users upar ON m.mmparID = upar.uID 
    LEFT JOIN users upre ON m.mmpreID = upre.uID 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a problem combining two WHERE statements in the following SQL statement
We're having a problem combining 'nested files' and excluding files from source control. We're
We're having problem with a huge number of legacy stored procedures at work. Do
We are having problem with the server migration. We have one application that are
Following on from a previous question , I am having trouble combining the Lazy<T>
Having dutifully normalised all my data, I'm having a problem combining 3NF rows into
I'm having a problem compiling an application which uses Core-Plot in debug mode. It
Essentially, after compiling utility jars w/ ANT, I'm having the problem that all the
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.