加快行计数并加入MySQL中的2个表

时间:2016-01-08 09:50:48

标签: mysql

我有2张桌子,优惠券和coupon_click  这个查询花了很长时间:

$this->db->select('coupons.*, COUNT(coupon_click.coupon_id) max_rating');
$this->db->from('coupons');
$this->db->join('coupon_click', 'coupons.id = coupon_click.coupon_id');
$this->db->where('coupons.enabled',1);
$this->db->group_by(array("coupons.id", "coupon_click.coupon_id")); 
$this->db->order_by('date_added','desc');
$top_coupons =$this->db->get()->result();

任何帮助请如何加快此查询? 谢谢你们

0 个答案:

没有答案
相关问题