在一个部分工作以获得同一查询中交易的平均评分,这些是详细信息,
avg(rv.ratevalue) as avRatings
$this->db->join('product_rating rv','rv.productid = b.dealId','left');
$this->db->where('b.categoryId',$categoryId);
返回0结果,预计为4。如果我删除类别条件将返回4 insted 0.无法检测到问题。
完整查询是 -
SELECT `b`.`deal_available_city`, `b`.`shippingType`, `b`.`priceType`, `b`.`dealId`, `b`.`dealUrl`, `b`.`dealTitle`, `b`.`slug`, `b`.`dealDetails`, `b`.`extraDetails`, `b`.`isHomeScreenBigDeal`, `b`.`deal_available_city`, `b`.`aditionalDetails`, `b`.`status`, `b`.`dateAdded`, `b`.`categoryId`, `b`.`siteId`, `b`.`isPinned`, `b`.`priceId`, `b`.`price`, `b`.`startDate`, `b`.`endDate`, `b`.`NumberOfClicked`, `b`.`discountPrice`, `b`.`discountPercentage`, `b`.`dealBrandId`, `b`.`endTime`, `b`.`startTime`, `b`.`howtousethisoffer`, `b`.`deal_location`, `b`.`cancellationpolicy`, `b`.`dealType`, `b`.`totalavailabledeals`, `b`.`numberofdealused`, `b`.`addedTime`, `i`.`thumbImage`, `i`.`imageUrl`, `i`.`normalimageurl`, `s`.`SiteUrl`, `s`.`SiteName`, `s`.`Site_alias`, `s`.`SiteLogo`, `c`.`cat_name`, `c`.`cat_color`, `c`.`cat_alias`, `p`.`price_name`, `p`.`price_symbol`, `p`.`price_shortcode`, `st`.`shId`, `st`.`shipping_text`, `l`.`user_id` as `isMarkedFavourite`, `dt`.`user_id` as `islikedorDisliked`, avg(rv.userid) as avRatings FROM `cob_dealdetails` as `b` LEFT JOIN `cob_dealImages` `i` ON `i`.`dealId` = `b`.`dealId` LEFT JOIN `cob_brand` `s` ON `s`.`SiteId` = `b`.`siteId` LEFT JOIN `cob_shipping_details` `st` ON `st`.`shId` = `b`.`shippingType` LEFT JOIN `cob_price_type` `p` ON `p`.`id` = `b`.`priceId` LEFT JOIN `cob_coupon_category` `c` ON `c`.`catId` = `b`.`categoryId` LEFT JOIN `cob_dealfavorite` `l` ON `l`.`deal_id` = `b`.`dealId` AND `l`.`user_id` = 3259 LEFT JOIN `cob_deallike` `dt` ON `dt`.`deal_id` = `b`.`dealId` AND `dt`.`user_id` = 3259 LEFT JOIN `cob_product_rating` `rv` ON `rv`.`productid` = `b`.`dealId` WHERE `b`.`showinhomescreen` = '1' AND `i`.`imgisdefault` = '1' AND `i`.`status` = '1' AND `i`.`imageOrder` = '1' AND FIND_IN_SET(1,b.deal_available_city) !=0 AND `b`.`startTime` <= '2017-07-22 19:00:09' AND `b`.`endTime` >= '2017-07-22 19:00:09' AND `b`.`categoryId` = '2' GROUP BY `b`.`dealId` ORDER BY `b`.`dealId` DESC LIMIT 10