![](/img/trans.png)
[英]How to get values from another table in codeigniter using the Active Record?
[英]How to get count of a field in another table codeigniter using group by?
我不太清楚您桌子的设计,所以我必须安全地将两张桌子合在一起
SELECT a.org_id, a.licenses, b.used_key from sitekeys a LEFT JOIN ( SELECT site_key, user_id, count(site_key) as used_key FROM activation b GROUP BY site_key,user_id ) b on a.site_key = b.site_key
$this->db->select("count(activation.site_key)");
$this->db->from("activation");
$this->db->join("sitekeys");
$this->db->group_by("sitekeys.site_key");
$this->db->get();
尝试这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.