1:product_version 2: p_category 3:p_category_product
select
pc.name as "产品类别",
pv.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
left join p_category_product pcp on pcp.product_id=pv.product_id
left join p_category pc on pc.id=pcp.p_category_id
where pv.sale_on_class=1 and pv.status=1
order by 2 desc;
引用
select
pc.name as "产品类别",
pv.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
left join p_category_product pcp on pcp.product_id=pv.product_id
left join p_category pc on pc.id=pcp.p_category_id
where pv.sale_on_class=1 and pv.status=1
order by 2 desc;

本文介绍了一种从产品版本表中查询特定产品信息的方法。通过SQL语句实现对产品ID、名称、价格等字段的选择,并根据销售状态和产品状态进行过滤。

1万+

被折叠的 条评论
为什么被折叠?



