![](/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.