SELECT if(ecs_goods_attr.buy_price is null,ecs_goods.buy_price,ecs_goods_attr.buy_price+ecs_goods.buy_price) AS buy_price
FROM ecs_order_info
LEFT JOIN ecs_order_goods using(order_id)
LEFT JOIN ecs_goods using(goods_id)
LEFT JOIN ecs_goods_attr using(goods_attr_id)
WHERE order_id=224;
字段如果是null值的话。结果会变成null值.所有可以上加if来判断;