product_id是多个重复的,需求是每个product_id只取一条,并且id倒序排列。
SQL语句:SQL语句:
SELECT * from (
SELECT * from shop_product_snapshot GROUP BY product_id,id ORDER BY product_id,id DESC
) AS shop_product_snapshot GROUP by product_id ORDER BY `id` DESC
product_id是多个重复的,需求是每个product_id只取一条,并且id倒序排列。
SQL语句:SQL语句:
SELECT * from (
SELECT * from shop_product_snapshot GROUP BY product_id,id ORDER BY product_id,id DESC
) AS shop_product_snapshot GROUP by product_id ORDER BY `id` DESC