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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:57:57+00:00 2026-05-21T14:57:57+00:00

I need to join a contact table (contacts) that contains names multiple times in

  • 0

I need to join a contact table (contacts) that contains names multiple times in a query in order to get both parent and child names. I also need to join a table that has the parent-child relationship so I know which child belongs to which parent (childs_caregiver). The below query is getting me parent and child names but not attaching the correct parent to child–it’s just running all possible records. I don’t know how to join the parent-child relationship table properly (by childcaregiverID).

select c.contactid, ct.contactid,
 c.lastname as 'Parent Last Name', c.firstname as 'Parent First Name', c.address, c.city,
c.state, c.postalcode, c.homephone, c.workphone, ct.lastname as 'Child Last Name', ct.firstname as 'Child First Name'
from contacts c
inner join childs_caregivers cc on c.contactid=cc.caregiverid, 
contacts ct
inner join childs_caregivers cs on ct.contactid=cs.childid,
contacts cts
inner join childs_caregivers cv on cts.contactid=cv.childcaregiverid
where c.caregiver=1

Thanks for looking!

  • 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-21T14:57:58+00:00Added an answer on May 21, 2026 at 2:57 pm

    You’re joining c, ct, and cts with childs_caregivers, but not with each other. If there is a hierarchical relationship between multiple contact records, you need to express this in your DDL (schema). Add a column for parent_id and for “child” records, specify the primary key for the contact that is the “parent”. Then join the contact tables together in your WHERE statement.

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

Sidebar

Related Questions

I need to do a join with a table/result-set/whatever that has the integers n
I have table with contacts identified by LOOKUP_KEY and I need JOIN it with
I have 3 tables I need to join. The contracts table is the main
I have an array in javascript that I need to join and send through
I have a table with more than 100 columns. I need to join it
I need help regarding JOIN tables to get category name & author name from
This is my query thus far: select C.ACCOUNTNO,C.CONTACT,KEY1,KEY4 from contact1 C left join CONTSUPP
I'm trying to write a join statement, but am finding that the query I'm
I have the following query and I need to implement a Mailer that needs
I'm trying to order a grouped resultset. Problem is that one of the join

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.