Jump to content
Tedy

c# and mysql

Recommended Posts

salut, momentan lucrez la un proiect in c# care foloseste "la greu" mysql...(problema e ca nu sunt foarte prieten cu mysql) ...

deci am urmatoare problema:

am 3 tabele:

tab1:

ID| Ingrediente| Cant_disponibila

1 | mere | 250

2 | pere | 14

3 | nuci | 111

tab2:

ID_Recipe| Denumire

1 | mere

2 | pere

3 | nuci

tab3:

ID| Recipe_ID |Ingrediente_ID | Cant_necesara

1 | 1 | 7 | 250

2 | 1 | 5 | 14

3 | 2 | 6 | 111

4 | 2 | 1 | 111

5 | 2 | 2 | 111

eu trebuie sa fac urmatorul task: sa scad din cant_disponibila in functie de reteta selectata cant_necesara si sa fac update cu diferenta lor, in cant_disponibila...

later edit : query in mysql este asta:

UPDATE tab1 JOIN tab3 ON (ID = Ingrediente_ID) JOIN tab2 ON (ID_Recipe = Recipe_ID) SET Cant_disponibila = Cant_disponibila - Cant_necesara WHERE Denumire = "...";

Problema este ca imi "arunca" o eroare in momentul in care execut query-ul in aplicatia c#....

Link to comment
Share on other sites

da, ai dreptate redox , acum primisem raspuns si pe stackoverflow , e tot ceva de forma a ceea ce ai zis tu , doar ca a redenumit tabelele

UPDATE a SET a.Cant_disponibila = a.Cant_disponibila - c.Cant_necesara FROM tab1 a INNER JOIN tab3 c ON a.ID = c.Ingrediente_ID INNER JOIN tab2 b ON b.ID_Recipe = c.Recipe_ID WHERE b.Nume =

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...