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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:08:52+00:00 2026-05-26T02:08:52+00:00

I have a table in my database called characters. It tracks a character ID,

  • 0

I have a table in my database called characters. It tracks a character ID, name, marriedto, and fathersID. “marriedto” is the Character ID of a character they are wed to, and “fathersID” is the character ID of that character’s father.

I’d like to do a join statement in SQL that will pull all three names.
So my table might look like this:

CharID CharName marriedto fatherID
1      Jeremy   2         3
2      Sarah    1         4
3      Charles  5         6

I want to run a query to return something along these lines

Jeremy, Sarah, Charles

I can get one join on itself to happen, if I want it to give me just two names, but three is escaping me.

This works for two..

"SELECT C1.name AS spouse1, C2.name AS spouse2 
        FROM characters AS C1 
            JOIN characters AS C2 
                ON C1.marriedto= C2.characters_ID";

And I have attempted this for three, but it does not work.

"SELECT C1.name AS spouse1, C2.name AS spouse2 C3.name AS father
        FROM characters AS C1 
            JOIN characters AS C2 
                ON C1.marriedto= C2.characters_ID
            LEFT JOIN characters AS C3
                ON C1.fathersID = C3.characters_ID"

How can I do this triple join of just 1 table?

  • 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-26T02:08:53+00:00Added an answer on May 26, 2026 at 2:08 am

    Your query looks fine.. I can see only a comma missing between spouse2 and C3.name.

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

Sidebar

Related Questions

I have a mysql database table called character with columns like name, strength, intelligence,
Lets say I have a database table called Scrape possibly setup like: UserID (int)
I have a database table called users This table has two columns (that are
I have a database table called posts that has 'id, title, slug and content'
I have a database table called settings, and in that table I've got 2
Let's say I have a table in my database called Orders that has the
I i have a SQL Server database table called tbl_faults . In that table
I have a database table called Posts which stores all the information regarding an
Lets say I have a table in a sql server 2000 database called TransactionType:
I have a simple database table called Entries: class CreateEntries < ActiveRecord::Migration def self.up

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.