I have a table in mysql that has a number of contracted items.
Table itens_contratados
contracted id
Item
Qtd_contracted
Table servico
, in this I inform the service that I executed in the contract
contract_id
I want to make a query that tells me this:
itens_contratados.id_contratado itens_contratados.qtd_contratada servicos.qtd_servico saldo
Where qtd_servico
is equal to the number of records found in the servico
table for id_contratado
and saldo
= qtd_contratada
- qtd_servico