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

  • Home
  • SEARCH
  • 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 773449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:58:00+00:00 2026-05-14T18:58:00+00:00

I have three tables Prospect — holds prospect information id name projectID Sample data

  • 0

I have three tables

Prospect — holds prospect information

id
name
projectID

Sample data for Prospect

id | name | projectID
1  |  p1  |  1
2  |  p2  |  1
3  |  p3  |  1
4  |  p4  |  2
5  |  p5  |  2
6  |  p6  |  2

Conjoint — holds conjoint information

id
title
projectID

Sample data

id | title  | projectID
1  | color  |  1
2  | size   |  1
3  | qual   |  1
4  | color  |  2
5  | price  |  2
6  | weight |  2

There is an associative table that holds the conjoint values for the prospects:

ConjointProspect
id
prospectID
conjointID
value

Sample Data

id | prospectID | conjointID | value
1  |      1     |      1     |   20
2  |      1     |      2     |   30
3  |      1     |      3     |   50
4  |      2     |      1     |   10
5  |      2     |      3     |   40

There are one or more prospects and one or more conjoints in their respective tables. A prospect may or may not have a value for each conjoint.

I’d like to have an SQL statement that will extract all conjoint values for each prospect of a given project, displaying NULL where there is no value for a value that is not present in the ConjointProspect table for a given conjoint and prospect.

Something along the lines of this for projectID = 1

prospectID  | conjoint ID  | value
    1       |      1       |   20
    1       |      2       |   30
    1       |      3       |   50
    2       |      1       |   10
    2       |      2       |   NULL
    2       |      3       |   40
    3       |      1       |   NULL
    3       |      2       |   NULL
    3       |      3       |   NULL

I’ve tried using an inner join on the prospect and conjoint tables and then a left join on the ConjointProspect, but somewhere I’m getting a cartesian products for prospect/conjoint pairs that don’t make any sense (to me)

SELECT p.id, p.name, c.id, c.title, cp.value
FROM prospect p
INNER JOIN  conjoint c ON p.projectID = c.projectid
LEFT JOIN conjointProspect cp ON cp.prospectID = p.id
WHERE  p.projectID = 2
ORDER BY p.id, c.id

prospectID  | conjoint ID  | value
    1       |      1       |   20
    1       |      2       |   30
    1       |      3       |   50
    1       |      1       |   20
    1       |      2       |   30
    1       |      3       |   50
    1       |      1       |   20
    1       |      2       |   30
    1       |      3       |   50
    2       |      1       |   10
    2       |      2       |   40
    2       |      1       |   10
    2       |      2       |   40
    2       |      1       |   10
    2       |      2       |   40
    3       |      1       |   NULL
    3       |      2       |   NULL
    3       |      3       |   NULL

Guidance is very much appreciated!!

  • 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-14T18:58:01+00:00Added an answer on May 14, 2026 at 6:58 pm

    Then this will work for you… Prejoin a Cartesian against all prospects and elements within that project via a select as your first FROM table. Then, left join to the conjoinprospect. You can obviously change / eliminate certain columns from result, but at least all is there, in the join you want with exact results you are expecting…

    SELECT 
           PJ.*,
           CJP.Value
        FROM 
           (   SELECT 
                       P.ID ProspectID,
                       P.Name,
                       P.ProjectID,
                       CJ.Title,
                       CJ.ID ConJointID
                   FROM 
                       Prospect P,
                       ConJoint CJ
                   where 
                           P.ProjectID = 1
                       AND P.ProjectID = CJ.ProjectID
                   ORDER BY 
                       1, 4
             ) PJ
             LEFT JOIN conjointProspect cjp 
                 ON PJ.ProspectID = cjp.prospectID 
                AND PJ.ConjointID = cjp.conjointid
         ORDER BY 
            PJ.ProspectID,
            PJ.ConJointID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I have two tables Boxer and Prospect. Boxers has general stuff like name and
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three tables. This query will write down the right answer (x-lines for
Assuming I have three tables : TableA (key, value) TableB (key, value) TableC (key,
Well here's my problem I have three tables; regions, countries, states. Countries can be
I have a MySQL Left Join problem. I have three tables which I'm trying
Hi I'm using ms2005 for a simple calendaring system. We have three 'legacy' tables:

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.