GROUP BY 和 ORDER BY 子句联合使用组合查询

转http://lzfhope.blog.163.com/blog/static/636399220092554045196/

SELECT g.product_id,g.promotion_price FROM sdb_starbuy_special_goods g
                LEFT JOIN sdb_b2c_products p on g.product_id = p.product_id
                WHERE g.begin_time <".time()." AND g.end_time > ".time()." AND g.`status` = TRUE and g.type_id = 2  GROUP BY p.goods_id order by product_id DESC limit 5

你可能感兴趣的:(MYSQL)