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 ('15','509','538','535','532','529','542','526','539','536','533','530','527','540','537','534','531','528','541','525','513','570','585','601','582','598','580','595','577','592','574','589','571','586','602','583','599','581','596','578','593','575','590','572','587','584','600','597','579','594','576','591','573','588','508','522','519','516','523','520','517','524','521','518','515','514','617','614','611','608','624','605','621','618','615','612','609','625','606','622','603','619','616','613','610','626','607','623','604','620','510','551','548','545','552','549','546','543','553','550','547','544','511','554','564','561','558','555','562','559','556','563','560','557','512','567','568','565','569','566') OR g.goods_id IN ('') ) AND g.supplier_id=0 ORDER BY salenum DESC LIMIT 36 |