我有两个表一个是有关位置的出口详细信息,一个是否为。该特定商店的优惠,我想加入两个表来展示商店和他们各自的优惠和位置,我通过加入表成功获取商店和他们的优惠,但我想如何计算没有。特定地点的优惠。我加入表的SQL查询是
$sql_2="SELECT p.id,p.outlet_id,p.offer_title,p.original_price,
p.discount,p.discount_price,p.offer_image,p.offer_details,
o.outlet_id,o.outlet_title,o.outlet_locality,o.segment_type
FROM products as p,outlets as o
WHERE p.outlet_id=o.outlet_id AND o.segment_type='$category'
GROUP BY o.outlet_locality ";
从上面我可以了解一组地方,我想计算总报价,即。 ALL()和个人所在地提供个性化服务 我的HTML是'
<h3>Location</h3>
<ul class="offer-location" >
<li class="checkbox">
<label>
<input type="checkbox" class="i-check">All <small>(657)</small>
</label>
</li>
<?php
foreach($qry_2 as $v2){
?>
<li class="checkbox">
<label>
<input type="checkbox" class="i-check"/>
<?php echo $v2['outlet_locality'] ?> <small>(120)</small>
</label>
</li>
<?php
}
?>
</ul>
答案 0 :(得分:0)
$sql_2="SELECT p.id,p.outlet_id,p.offer_title,p.original_price,
p.discount,p.discount_price,p.offer_image,p.offer_details,
o.outlet_id,o.outlet_title,o.outlet_locality,o.segment_type, count(p.outlet_id) as outletCount
FROM products as p,outlets as o
WHERE p.outlet_id=o.outlet_id AND o.segment_type='$category'
GROUP BY o.outlet_locality ";