多次使用 left join 左连接 多个表

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/wentao365/article/details/83849967
[b]1:product_version 2: p_category 3:p_category_product [/b]
[quote]
select
[b]pc.[/b]name as "产品类别",
[b]pv.[/b]product_id "产品ID",
pv.version_id as "版本ID",
pv.name as "产品名称",
pv.price as "原价",
pv.curr_price "现价",
pv.onsale_time as "上架时间",
decode(pv.cost_type,1,'按次',2,'包时段',3,'按课时',4,'免费') as "计费类型",
case
when pv.cost_type=2 and pv.useful_life_type=1 then '有效天数'
when pv.cost_type=2 and pv.useful_life_type=2 then '截止日期'
end as "有效期类型",
pv.end_date as "过期时间"
from product_version pv
[b]left join p_category_product[/b] pcp on pcp.product_id=pv.product_id
[b]left join p_category pc[/b] on pc.id=pcp.p_category_id
where pv.sale_on_class=1 and pv.status=1
order by 2 desc;
[/quote]
展开阅读全文

没有更多推荐了,返回首页