Hi all!
This is my scenario where I need help:
I purchase food raw materials (such as Rice, Oil, Salt, Sugar, Soda, Coffee, Maize etc), I record this in the inventory table
I record to the system (table menu), types of foods I will be making (we call it menu), menu can be something like (Rice with Fish, Salad, Coffee, Soda, Pizza etc)
I also record to the system (table recipe) what raw materials makes up each of the menu I specified above, and what amount of the raw material. (look like this Rice & Fish :20units of Rice, 1 fish, 2 units of salt), this for every other menu/food listed in paragraph 2 above.
When I sell the food/menu, I want the appropriate amount of its recipes to be subtracted from the total that is available in the main Inventory table. So, if I sold 1 Rice&Fish, I want the system to subtract 20units of rice, 1fish,2Units of salt from the inventory table. (This is where I get into trouble)
In my trying, I decided to create three tables (Inventory,Menu & Recipe), I am attaching a snapshot of how I designed the tables, please have a look. (Please note that in table recipe, menuID & InvID are foreign key)
Now, FROM THE TABLES (see attached)
If I sell (Click) “Salad” I will run the querry
(This give me: Water (20), Salt (30)), according to the values I had specified in the other tables.
Now my problem is, how can I deduct this (Water (20), Salt (30)) from their respective amounts in the Inventory table?
How can I read what is in the inventory table and subtract the two-column results of a query?
Can looping be used to do this? This confuses me and I would appreciate some help.
*Sorry if I did not explain myself clearly, and thanks for continued support.
Database: mysql.
- "SELECT InvID,quantity FROM Recipe WHERE menuID = '" & Me.ComboBoxMenu.Text & "'" '(selected here in this combobox is e.g. "Salad")
- Add new comment
- 49 views