SQL | SELECT IFNULL(o.num,0) AS salenum, g.goods_id, g.goods_name, g.click_count, g.goods_number, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, IFNULL(mp.user_price, g.shop_price * '1') AS shop_price, g.promote_price, g.goods_type, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM `lggemuterc`.`tww0ogj_goods` AS g LEFT JOIN `lggemuterc`.`tww0ogj_member_price` AS mp ON mp.goods_id = g.goods_id AND mp.user_rank = '0' LEFT JOIN (SELECT SUM(og.`goods_number`) AS num,og.goods_id FROM ecs_order_goods AS og, ecs_order_info AS oi WHERE oi.pay_status = 2 AND oi.order_status >= 1 AND oi.order_id = og.order_id GROUP BY og.goods_id) AS o ON o.goods_id = g.goods_id WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.cat_id IN ('7','20','458','49','456','46','43','459','50','47','455','44','41','460','51','457','48','45','42','474','477','478','479','17','23','30','27','24','454','28','25','452','29','26','21','55','52','56','53','54','475','493','490','506','487','503','500','484','497','481','494','491','507','488','504','485','501','498','482','495','492','489','505','486','502','499','483','496','480','18','461','33','462','34','31','463','35','32','464','22','65','471','62','468','59','465','66','472','63','469','60','466','57','473','64','470','61','467','58','19','39','36','40','37','38') OR g.goods_id IN ('') ) ORDER BY salenum DESC LIMIT 36 |