Ok.. heres the deal.. im making one of those fancy navigation bars where
you can see how deep and where you are in the navigation structure like this:
each of them is a link.. all i need in each of them is the id that belongs to the name.
tutorials -> scripting -> php
I have 3 tables:
lets say i browse the subCategories..
I want to use a query that lets me:
[retrieve sectionName by joining subCat.sectionID on section.sectionID] and
[retrieve catName by joining subCat.catID on category.catID]
Thus i shall end up with 6 values: subCatID and name, catID and name, sectionID and name.
so far ive built this query:
SELECT section.sectionName, subCat.sectionID, category.catName, subCat.catID, subCat.subCatID, subCat.subCatName
FROM section, category, subCat
INNER JOIN category ON category.catID = subCat.catID
INNER JOIN section ON section.sectionID = subCat.sectionID
WHERE subCat.subCatID = '$subCatID'";
But it doesnt work.
do anybody know have a clue about how my query needs to look like?
The mySQL manual itself is located at http://www.mysql.com/doc/search.php
but the article on chaining inner joins is not there. I must have gotten confused with a SQL tutorial that I read in a book. Sorry. Basically the parentheses act in a similar manner to parentheses in mathematical statements, forcing the computer to perform those operations first. In this case, it allows you to join 2 tables first and then join the 3rd to it. If they are unnecessary, MySQL ignores them anyways.