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

  • Home
  • SEARCH
  • 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 181099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:42:07+00:00 2026-05-11T14:42:07+00:00

I have a mysql question. I have an application which I am migrating to

  • 0

I have a mysql question.

I have an application which I am migrating to PHP/Mysql from Coldfusion and MSSql.

There are categories and sub-categories (with apparently unlimited sub-categories).

What is the best way to grab all of the records in a products table given a navigationID.

there are two tables I am dealing with. One is the Products table (which has a nav_id corresponding to —>) and the other is a category relationship table which includes parent/child relationships.

So essentially I want to query the two tables to produce all of the products associated with a navigationID and that NavigationID’s sub categories.

any ideas or directions? I know this has to be done. Was thinking the answer would lie in a nested query but cannot wrap my head around it.

Nav_table – contains

ChildNavId      int(11) ParentNavId     int(11) 

Products_Table – contains

productNavID    int(11) // productNavID contains the lowest level NavID  
  • 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. 2026-05-11T14:42:08+00:00Added an answer on May 11, 2026 at 2:42 pm

    There are categories and sub-categories (with apparently unlimited sub-categories).

    If by this you many there are arbitrarily many levels of category nesting, you can’t grab them all with a single query using the ‘parent reference’ schema model. You would have to repeatedly query the children of each category you found, recursively, or just keep doing longer and longer self-joins until you’ve picked up the most-deeply-nested items.

    For single-query access to hierarchical data you will have to look into alternative ways of structuring the schema, principally:

    • Nested Sets: stores a numerical ordering of a recursive walk over the tree
    • Adjacency Relation: adds extra ancestor/descendent pairs to your child/parent lookup

    Either or both of these approaches, in one of their flavours, may work for you. (I usually end up with Nested Sets so that I get an explicit first-to-last order as well.)

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

Sidebar

Ask A Question

Stats

  • Questions 262k
  • Answers 262k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This extra step is mandatory in Oracle: you will have… May 13, 2026 at 11:47 am
  • Editorial Team
    Editorial Team added an answer Is there any documentation that gives a clear comparison (with… May 13, 2026 at 11:47 am
  • Editorial Team
    Editorial Team added an answer I lost hope with this one, and asked for an… May 13, 2026 at 11:47 am

Related Questions

I have an application which collects data into a mysql table. The table has
I have an application which uses Zend_Date to display dates. Zend_Date instances are created
I have a big doubt. Let's take as example a database for a whatever
I am developing an Erlang application which requires a LOT of DB writes. My

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.