1
Staff to making a query in 3 tables with Internet, follow the code:
select
itensVenda.idVenda, itensVenda.idProd, itensVenda.qtd,
produtos.id, produtos.descricao, produtos.foto,
venda.id, venda.valor
from produtos
INNER JOIN itensVenda ON produtos.id = itensVenda.idProd
INNER JOIN venda ON itensVenda.idVenda = venda.id
So far so good is taking everything, what I would like:
i have in itensVenda two equal sale id id in the last release, how can I redeem this release showing me the last idVenda?
example: I have two sale id 0009 and wanted to unite them
Try... ORDER BY idVenda DESC LIMIT 1
– Novaes
I believe that you need to group, you can put in the question an example of the data that returns?
– Ricardo Pontual
I tried this but back only one result being that I have two id sale
– kid Ferreira
he returns like this:
– kid Ferreira
I’ll post it like I did. select itensVenda.idVenda, itensVenda.idProd, itensVenda.Qtd, products.id, products.Description, products.photo, sale.id, sale.valor from products INNER JOIN itensVenda ON products.id = itensVenda.idProd INNER JOIN sale ON itensVenda.idVenda = sale.id WHERE itensVenda.idVenda = (SELECT MAX(id) FROM sale WHERE id = id) and on the page you call I’ve placed a javascript script redirecting like this: echo 'Location.href="ver_compra_final.php? id=$id"
– kid Ferreira