mysql if...else 的使用

select
        case when tca.id = '3' then 'vw'  else epc_code end as epccode,tfp.product_id, tfp.vender, tfp.spec_id, tfp.product_classify, tfp.supplier_id, tfp.classify, tfp.category, tfp.texture,
        tfp.stand_name, tfp.another_name, tfp.spec_name, tfp.spec_m, tfp.oem, tfp.factorynum, tfp.pics, tfp.unit, tfp.pac_spec,
        tfp.ourc_price, tfp.price, tfp.exp_date, tfp.capacity, tfp.stock_max, tfp.explains, tfp.goods_max, tfp.business_type,
        tfp.is_special, tfp.is_audit, tfp.is_show_company, tfp.is_show_brand, tfp.is_show_business, tfp.special_begin_time,
        tfp.special_end_time, tfp.market_enable, tfp.buy_count, tfp.remark, tfp.status, tfp.order_min, tfp.create_time,
        tfp.update_time, tfp.retail_price,tfp.master_graph,tar.local_name AS cityName ,
        tea.local_name AS provinceName,taq.quality_name AS qualityName,

        tpt.name AS classifyName,taso.special_price AS specialPrice
        from
        t_full_product_ford tfp
        left join t_company  tm ON tm.com_id = tfp.supplier_id
        LEFT JOIN t_area tea ON tm.province_id = tea.id
        LEFT JOIN t_area tar on tar.id = tm.city_id
        left join t_data_quality taq ON taq.quality_id = tfp.spec_id
        left JOIN  t_product_type tpt ON  tpt.s_id = tfp.category
        LEFT JOIN t_admin_special_offer taso on taso.product_id=tfp.product_id
				LEFT JOIN t_car_vender tca on tca.id=tfp.vender and epc_code=taso.table_name
        and taso.is_effective = 0
        and taso.end_time_special > now()
        and now() > taso.start_time_special_off
        where tfp.product_id = 1 and  tfp.market_enable = 1

  

转载于:https://www.cnblogs.com/EveningWind/p/10033090.html

你可能感兴趣的:(数据库)