By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,967 Members | 1,684 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,967 IT Pros & Developers. It's quick & easy.

Please Help!

P: n/a
I am building an app for a restaurant. The restaurant has multiple
menus. When the user comes to a page for a specific menu I need to
pull all item data from multiple database tables. There are multiple
categories of items, each item falls under a category. Some categories
have items that fall into sub categories.

I posted my database tables and a basic sample of the output below. I
know how to do this and it is easy if I create one huge table, but due
to the amount of data I am working with I need to make sure that this
is put together as efficiently as possible.

Is it possible to combine all of this into one SQL statement? Can
anyone offer a better way to make this work? Any thoughts would be
greatly appreciated. Thanks in advance.

I have three tables:

items
itemId (key)
itemName
itemDescription
price
menu
category
subCategory (could be '0' if item does not have subCategory)

menus
menuId (key)
menuName
menuDescription

menuCategories
categoryId (key)
category
menu
description

menuSubCategory
subCategoryId (key)
subCategory
menuId
categoryId

I want to print the output on the page in the following format:

Category

itemName, item description, price (if item has subCategory equal
to zero)

subCategory

itemName, item description, price

subCategory

itemName, item description, price

Repeat until all items in the query have been printed.
Aug 17 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
mpar612 wrote:
I am building an app for a restaurant. The restaurant has multiple
menus. When the user comes to a page for a specific menu I need to
pull all item data from multiple database tables. There are multiple
categories of items, each item falls under a category. Some categories
have items that fall into sub categories.

I posted my database tables and a basic sample of the output below. I
know how to do this and it is easy if I create one huge table, but due
to the amount of data I am working with I need to make sure that this
is put together as efficiently as possible.

Is it possible to combine all of this into one SQL statement? Can
anyone offer a better way to make this work? Any thoughts would be
greatly appreciated. Thanks in advance.

I have three tables:

items
itemId (key)
itemName
itemDescription
price
menu
category
subCategory (could be '0' if item does not have subCategory)

menus
menuId (key)
menuName
menuDescription

menuCategories
categoryId (key)
category
menu
description

menuSubCategory
subCategoryId (key)
subCategory
menuId
categoryId

I want to print the output on the page in the following format:

Category

itemName, item description, price (if item has subCategory equal
to zero)

subCategory

itemName, item description, price

subCategory

itemName, item description, price

Repeat until all items in the query have been printed.
This question would be more appropriate to ask in your database's
newsgroup, like comp.databases.mysql, unless you have a PHP-specific
problem somewhere.

--
Curtis
Aug 17 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.