Inner Join returning empty

0

I have a SELECT to return a list of products, but I want them to be differentiated by input and output, contains and does not contain ...

Note: I WANT TO GET THE LATEST MOVEMENT OF EACH PRODUCT

Select that I have so far

SELECT DISTINCT * 
FROM EstoqueGeral e
LEFT OUTER JOIN (

SELECT  * 
FROM produto_movimento 
GROUP BY codigoproduto
) AS mvp ON mvp.codigoproduto = e.codigo2

LEFT OUTER JOIN (
SELECT DISTINCT * 
FROM estoque_movimentacao
GROUP BY idmov
) AS em ON mvp.idmov = em.idmov

LEFT OUTER JOIN (

SELECT DISTINCT * 
FROM clientes2
GROUP BY ID_cliente
) AS c ON c.cpf = em.cliente

ORDER BY 'mvp'.'id_pm'  DESC
LIMIT 15

RETURN

TABLEMOVEMENT2

PRODUCTS3TABLE

MOVEDPRODUCTSTABLE4

CLIENTSTABLE5

    
asked by anonymous 22.12.2017 / 14:22

1 answer

0

It should not be showing because of INNER JOIN changes to LEFT JOIN only to see if it returns or tries it more it will get heavy or something of the gender

 SELECT * FROM EstoqueGeral e
    LEFT JOIN produto_movimento mvp 
        ON 
            mvp.codigoproduto = e.codigo2 AND 
            mvp.codigoproduto  = ( SELECT mvp2.codigoproduto FROM produto_movimento ORDER BY mvp2.codigoproduto DESC LIMIT 1 )
    
22.12.2017 / 15:58