MySQL LEFT JOIN, GROUP BY and ORDER BY not working as required

前端 未结 4 1835
清歌不尽
清歌不尽 2020-12-16 17:18

I have a table

\'products\' => (\'product_id\', \'name\', \'description\') 

and a table

\'product_price\' => (\'pro         


        
4条回答
  •  既然无缘
    2020-12-16 17:32

    You need to set aliases properly I think and also set what you are joining on:

    SELECT p.*, pp.price 
    FROM products AS p 
    LEFT JOIN product_price AS pp
    ON pp.product_id = p.product_id 
    GROUP BY p.product_id 
    ORDER BY pp.date_updated DESC
    

提交回复
热议问题