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 9320121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:33:28+00:00 2026-06-19T03:33:28+00:00

This query returns ONLY the primary records who filled out the question 11042 and

  • 0

This query returns ONLY the primary records who filled out the question 11042 and answered “Yes”. Fine great no prob. But This primary may possibly have group members assigned under them that may also need to pull into this search query. HOWEVER they do not answer the question 11042 so arent in the fields t2 table. They are however in another table grpMems t3, lets say, which is also joined on id. So my question is how do i display both, primarys who answered the question yes and are thus in the t2 table, AND the group members who are in another t3 table for the search results?

select t1.id,t1.firstname,t1.lastname,t2.field1,t2.field2
from names t1
inner join fields t2 on t1.id=t2.id and t2.field1=2388 and t2.field2=11042 and t2.field3='Yes' 
where 1=1
<cfif searchby>
and t1.firstname like '%#searchFIRST#%'
</cfif>
order by t1.lastname,t1.firstname
  • 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-06-19T03:33:30+00:00Added an answer on June 19, 2026 at 3:33 am

    Using two left joins and requiring a minimum of one of them to have data:

    SELECT ...
    FROM names t1
    LEFT OUTER JOIN fields t2 ON ...
    LEFT OUTER JOIN another t3 ON ...
    WHERE t2.id IS NOT NULL OR t3.id IS NOT NULL
    

    If any of these relationships are many-to-many, you will need to do something to weed out duplicates though.


    Using a union:

    SELECT ...
    FROM names t1
    INNER JOIN fields t2 ON ...
    UNION ALL
    SELECT ...
    FROM names t1
    INNER JOIN another t3 ON ...
    

    Again if you have duplicates you will either need to use a UNION to weed them out or do something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone explain why this query returns an empty result. SELECT * FROM (`bookmarks`)
I'm gettintg crazy with the result of this query This query returns 29.970 rows
I have this query that returns the results by ordering it by focus.name ASC.
I have this query which returns a result set with Date(column) as nvarchar datatype.
Mysql query returns result like this collector amount name 1 0.00 gihan 1 2000.00
I have a LINQ query that returns some object like this... var query =
My query is not returning the expected amount of records the first part returns
I have this query: select qa_returns_items.item_code, (CASE status_code WHEN 11 THEN (qa_returns_items.item_quantity - qa_returns_residues.item_quantity)
how set distinct to this query return _dataContext.ProjectPictures.Include(Projects).Include(ProjectPictureTypes).Where(p => p.ProjectPictureTypes.Id == 1).ToList(); i need
I'm trying to get the IsAdmin Value with SQL query(This query return 1 line

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.