0
I have a table in mysql that has a number of contracted items.
Table itens_contratados
id_hired
Item
Qty contract
Table servico
, in this I inform the service I performed in the contract
id_hired
I want to make a query that informs me so:
itens_contratados.id_contratado itens_contratados.qtd_contratada servicos.qtd_servico saldo
Where qtd_servico
is equal to the amount of records found in the table servico
concerning the id_contratado
and saldo
= qtd_contratada
- qtd_servico
It would be interesting to put the structure of your tables and some data in this link: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&sqi=2&ved=0ahUKEwif-r3r34bVAhXJDpAKHeI1ApoQFggjMAA&url=http%3A%2F%2Fsqlfiddle.com%2F&usg=Afqjcnfm12txauoyr1fcpsh3njbga9q20a makes it easy for us to test the
query
before putting as an answer– Roberto de Campos
ok buddy, but I can’t put the table structure. I want something generic.... this data is not my table. I want to understand the logic
– Andre Maia
Okay, I’ll do something generic
– Roberto de Campos
Thank you! for the help!
– Andre Maia