As in SQL, the percent. to work with the two-dimensional table?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
58 views
There are the following tables:

  • The warehouse of raw materials: (ID, name, unit, price, quantity)
  • Warehouse products: (ID, name, unit of measure, amount, quantity)
  • Ingredients: (ID, products, raw material, quantity)


Ingredients - this recipe, which can be from raw materials, assemble products.

I known the product key that you need to make. Next, I need to choose all the ingredients for a desired product. Then, compare the amount of each of the necessary raw materials in the warehouse, required. If I have enough for each position of the required raw materials, to take the required number of ingredients from the warehouse of raw materials and produce 1 unit of output.

The idea is, it needs to produce 1 SQL procedure. After I get the list of ingredients (id_ингредиент, trabalhista), I have a two-dimensional table, and to work in SQL I can't with her.
I heard a little bit about cursors, to work with them do not know how, and it's due tomorrow.
In General, the program I have done, but the most part of calculations goes in the client part, because several times I pulled the DB and get all the classes fields.

I like this approach do not like, and I would like to know how you could do this job?
by | 58 views

2 Answers

0 like 0 dislike
skip to examples of M-to-N

to accelerate
M - raw
N - products
ingredients - a bunch between them (expands the classics only by the number)
by
0 like 0 dislike
you could do this job?
heard about cursors
Still, Yes, stored procedure for loop cursor in a transaction.
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,253 users