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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:47:31+00:00 2026-06-13T10:47:31+00:00

Using MySQL how can I make this hierarchy work? Parent’s ID is 100. This

  • 0

Using MySQL how can I make this hierarchy work?

  • Parent’s ID is 100. This Parent has a ParentID of 0.
  • Child has an ID of 101. The ParentID is 100.
  • SubEntity has an ID of 105. The ParentID is 100.
  • Child of Subentity has an ID of 106. Their ParentID is 105.

This query will be plugged into iReport. Currently the Subentity and it’s children do not roll up into the Parent.

This is what I ended up going with:

`Select
case
when FC.ParentType = 'PARENT' then FC.FundCode
when FB.ParentType = 'PARENT' then FB.FundCode
when F.ParentType = 'PARENT' then F.FundCode
else 0 end as `ParentID`,
case
when FB.ParentType = 'SUBFUND' then FB.FundCode
when F.ParentType = 'SUBFUND' then F.FundCode
else 0 end as `SubfundID`,
case
when FB.ParentType = 'CHILD' then FB.FundCode
when F.ParentType = 'CHILD' then F.FundCode
else 0 end as `Children`,            
F.FundName     
From Fund F
join Fund FB on F.ParentId = FB.FundCode
join Fund FC on FB.ParentID = FC.FundCode`
  • 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-13T10:47:32+00:00Added an answer on June 13, 2026 at 10:47 am

    Is there a static number governing how many levels this parent-child relationship has?

    Yes: Use recursive LEFT JOINs X times.

    SELECT *
    FROM table t1 LEFT JOIN table t2
      ON t1.id = t2.parent_id
      LEFT JOIN table t3
      ON t2.id = t3.parent_id
      ...
    

    No: Accomplish this using separate queries until you have fleshed out your Parent/Child objects as far as you want. Make sure you have checks in place to avoid loops, ie. a child is a parent of its parent.

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

Sidebar

Related Questions

I need to make this implementation: I'm using Php and MySQL. As you can
How can I make a perfect backup of mysql database using mysqldump? When I
This is the last thing I'm gonna do, after I can make this work,
I'm trying to make this many-to-many join work with Flask-SQLAlchemy and two MySQL databases,
Can I create tables using Stored Procedures? I am using MySQL. I had searched
i can't display the image on my aspx view.. i'm using mysql as database
I'm using a MySQL database. I have a products database where users can search
i can connect mysql with java using eclipse in a java application with these
Using PHP, I can convert MySQL data or static table data to csv, Excel,
I was wondering how can I validate a single checkbox using PHP and MySQL.

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.