2
I wonder how do I bring a specific record of a fk, being that I have the table lodging and the table consumption
(with fk codHospedagem
). When I select some hosting, I click on the consumption button of my consumption screen.
I need to bring in the consumption records of that hosting that I select, because my select is not working, 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 ;
Hello, consider accepting my answer if it has been helpful to you. If you think she’s incomplete or doesn’t respond to you, make the appropriate comments so I can improve her.
– Ismael