I would like to know how to get a specific record of a fk, I have the hosting table and the consumption
(with codHospedagem
). When I select some hosting, I click on the consumption button of my consumption screen.
I need to bring into consumption the consumption records of that hosting that I select, because my select is not working, it only brings the empty line. Below the code:
SELECT c.codConsumo as Consumo,c.codHospedagem as Hospedagem ,
p.nomeProduto AS Produto,
c.quantidade, c.valorConsumo, c.status
FROM consumo c
INNER JOIN produto AS p ON p.codProduto = c.codProduto
INNER JOIN hospedagem AS H ON H.codHospedagem = C.codHospedagem
WHERE H.codHospedagem = c.codConsumo
ORDER BY c.codConsumo ;