[英]SQL query for distinct records
這是我的查詢
select
po.product_option_id,
po.product_id,
24 as option_id,
283 as option_value_id,
1 as quantity,
0 as subtract,
2.0000 as price,
'+' as price_prefix,
0 as points,
'+' as points_prefix,
0.00000000 as weight,
'+' as weight_prefix
from oc_product_option po
inner join oc_product_option_value pov
on po.product_option_id = pov.product_option_id
where po.option_id = 24
我需要針對po.product_id的不同記錄,現在它針對相同product_id返回多個記錄
任何建議將不勝感激
使用mysql group by
group by po.product_id
這將為您提供針對product_id的 不同記錄
select
po.product_option_id,
po.product_id,
24 as option_id,
283 as option_value_id,
1 as quantity,
0 as subtract,
2.0000 as price,
'+' as price_prefix,
0 as points,
'+' as points_prefix,
0.00000000 as weight,
'+' as weight_prefix
from oc_product_option po
inner join oc_product_option_value pov
on po.product_option_id = pov.product_option_id
where po.option_id = 24 group by po.product_id
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.