[thelist] more sql help
Paul Cowan
evolt at funkwit.com
Thu Nov 21 17:49:21 CST 2002
Hey Tom,
I'd love to help, but I'm not sure what this means:
> I want menuitems to also be able to be a subcategory of a category as well
Do you mean:
Category1
SubCategory1.1
MenuItem1.1a
MenuItem1.1b
SubCategory1.2
MenuItem1.2a
Category2
... etc ...
or do you mean that menuitems ARE actually subcategories? That is,
subcategories and menuitems are different things, on the same 'level'?
I'm just not clear on what you're trying to do... but I'm sure I can
help you if I can bring my thick head to understand.
If you're trying to reach my example above, I would suggest that
you have:
Category
--------
CategoryId
....... blah
SubCategory
-----------
SubCategoryID
CategoryID (references category.categoryid)
....... whatever
MenuItem
--------
MenuItemID
SubCategoryID
....... and so on
MenuItem would then just have a SubCategoryId, not a categoryID.
You'd end up with something like this:
$result = @mysql_query("SELECT menuitem.*, category.*, subcategory.*
FROM menuitem, category, subcategory WHERE (menuItem.subCategoryID =
subCategory.subCategoryID) and (subCategory.categoryID =
category.categoryID) ORDER BY category, subcategory, item");
But I'm not sure that that's what you want...
Cheers,
Paul
More information about the thelist
mailing list