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 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

Related Questions

I am in the process of building a PHP/MySql database application which could have
We have a web application that has been built using MySQL / PHP /
I have a question regarding the proper workflow of git in a PHP/MySQL workflow.
I am working on a Spring MVC application in which I have recently been
I am writing an email application that interfaces with a MySQL database. I have
Using PHP, I am building an application that is MySQL database resource heavy, but
The Problem We have a large web application that stores and displays sensitive HIPAA-related
I have an application where I am storing about 1kbyte of data every 0.1
I am trying to implement a rails Recipe application from the site http://oreilly.com/ruby/archive/rails-revisited.html .
I am working on an application that allows users to dynamically add questions to

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.