February 27, 201115 yr I am creating a pub site with food/ drink menu's. I am trying to make it as efficient as possible. I have it set up roughly like this: SELECT * FROM MenuList FOR EACH MenuList RESULT { <li> SELECT * FROM MenuCategory Category_1 SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCategory = MenuCategoryID FOR MenuItem { SHOW MENU ITEM DETAILS } Category_2 SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCatagory = MenuCatagoryID FOR MenuItem { SHOW MENU ITEM DETAILS } Category_3 SELECT * FROM MenuItem WHERE MenuList = MenuListID AND MenuCatagory = MenuCatagoryID FOR MenuItem { SHOW MENU ITEM DETAILS } </li> } This will show like this: Main Menu (MenuList) Starter (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) Main (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) Dessert (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) Special Menu (MenuList) Starter (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) Main (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) Dessert (MenuCategory) Item1 :: Description1 :: Price1 (MenuItem) Item2 :: Description2 :: Price2 (MenuItem) Item3 :: Description3 :: Price3 (MenuItem) My only issue is having a select statement for each item within the category. As I have them within <li> elements for the whole menu list's, I'm using jQuery to hide all <li> apart from the first. As it is self manageable, the client can add as many menus as possible. So, the risk is, if they create 10 menus, but with 6 categories & 50 items within each Category, the SELECT Statement within each Category could add up to 1000+ sql statements for the one page. My basic question after all that: Is there a way to split the sql statement by categories and show items via each split. If this makes sense, please could you help. Like I said, it works well but I don't want performance to be an issue for the client.
Create an account or sign in to comment