我无法找到加入多个选项的任何参考,例如下面的活动记录中的查询,有谁知道如何做到这一点?
select a1.act, a1.date, a2.clos
from
(
SELECT count( AccountActiveDate ) act, DATE_FORMAT( AccountActiveDate, '%Y-%m' ) date
FROM customert cust
GROUP BY YEAR( AccountActiveDate ) , MONTH( AccountActiveDate )
) a1
join
(
SELECT count( AccountClosedDate ) clos, DATE_FORMAT( AccountClosedDate, '%Y-%m' ) date
FROM customert cust2
GROUP BY YEAR( AccountClosedDate) , MONTH( AccountClosedDate)
) a2
ON a1.date = a2.date
答案 0 :(得分:1)
你可以像这样输入sql字符串:
$this->db->query('YOUR QUERY HERE')
示例:
$this->db->query('SELECT * FROM tbl_users WHERE age > 18');