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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:56:45+00:00 2026-05-25T06:56:45+00:00

I have one table that looks something like this: id parent_id name 1 0

  • 0

I have one table that looks something like this:

id  parent_id    name
1   0            page #1
2   1            Page #2
3   1            Page #3
4   2            Page #4

*parent_id* is realated to id.

page #4 is a child of page #2
and page #2 is a child of page #1
and so is page #3.

I need a mysql query that can get all children to, say id 1.
Which would return all these pages since all pages “master parent” (lol) is page #1.

  • 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-25T06:56:45+00:00Added an answer on May 25, 2026 at 6:56 am

    You basically have two options:

    • Using recursion, either in your application logic or in the query, if your RDBMS supports that

    • Storing left/right values for each node in your tree, which lets you easily find all the sub-tree of a node

    Both those options are covered in an excellent article at sitepoint, http://www.sitepoint.com/hierarchical-data-database/ (but it doesn’t cover RDBMS recursion, which yours probably don’t support anyway)

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

Sidebar

Related Questions

I have an in-memory table that might looks something like this: Favorite# Name Profession
I have a table that looks like something like this: timestamp value person ===============================================
I have a table that looks something like this: ID | Keyword | Category
I have a table that looks something like this CREATE TABLE MyTable( [RecordID] [bigint]
So, I have an app/assets/stylesheets/ directory structure that looks something like this: |-dialogs |-mixins
I've got a sqlite table actions that looks something like this: uuid varchar (36)
I have an Oracle table with data that looks like this: ID BATCH STATUS
I have a report that looks something like this: CompanyA Workflow27 June5 CompanyA Workflow27
If I had a SQL Server table that looks something like this with some
Lets say I have one table called REVIEWS This table has Reviews that customers

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.