|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
How to Query this (Category/Subjects-in-Category/Titles-in-Subject)
I am struggling with the best way to query this. I have three tables, Categories, Subjects, and Titles. A Title belongs to only one Subject, a Subject belongs to only one Category. Inversely, Categories can have multiple Subjects, Subjects can have multiple Titles. Categories has a main_id, Subjects are linked to Categories by the main_id and also have a sub_id, Titles are linked to Subjects by the sub_id.
What I want to do is run (hopefully only one) query and then output all results like this: Category -Subject --Title -Subject --Title --Title Category -Subject --Title --Title --Title -Subject ... So, I need to associate categories as the parent, subjects as the children of categories, and titles as the children of subjects. Is this possible to do with one query? Is there a good tutorial anyone knows on how I would structure such a query? |
|
#2
|
||||
|
||||
|
while not exactly on point, the article Rudy authored on the subject should give you the general idea of the query structure. only in your example you aren't self-joining.
__________________
Jeff Carouth's Homepage Accelerate Studio have i been exceptionally helpful today? feeling generous? |
|
#3
|
|||
|
|||
|
That looks promising, jcarouth!
I'll give it a reading (I obviously am not using the proper search terms in Google, I was looking for just such a page for the last 4 hours). |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > How to Query this (Category/Subjects-in-Category/Titles-in-Subject) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|