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 `shlgqdwjwcom`.`tww0ogj_goods` AS g LEFT JOIN `shlgqdwjwcom`.`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','22','471','57','468','465','64','61','472','58','469','466','65','62','473','59','470','467','66','63','60','19','38','39','36','40','37','475','487','503','484','500','481','497','494','491','507','488','504','485','501','482','498','495','492','489','505','486','502','483','499','480','496','493','490','506','20','456','41','51','48','459','45','42','455','49','460','46','457','43','50','47','458','44','17','25','29','454','26','23','30','27','452','24','28','21','54','55','52','56','53','18','35','462','32','463','33','464','34','461','31','474','478','479','477') OR g.goods_id IN ('') ) ORDER BY salenum DESC LIMIT 36 |