How to get the latest releases from an inner join

1

Personal to doing a query in 3 tables with inner join, follows 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 the items sale two id sell same in the last release, how can I redeem this release showing me the last idVenda? example: I have two id sale 0009 and wanted to unite them

    
asked by anonymous 30.08.2018 / 22:41

1 answer

0

I'll post as I did.

select items.sales.id, items.products.id, products.id, products.id, products.description, products.foto, venda.id, sale.value from products INNER JOIN itemsSale ON products.id = items Sale.idProd INNER JOIN sale ON items sale.id sale = sale.id WHERE items sale.id sale = (SELECT MAX (id) FROM sale WHERE id = id)

and in the page that calls I put a script in javascript redirecting like this:

echo 'location.href="ver_compra_final.php? id = $ id";';

    
31.08.2018 / 00:35