【问题标题】:codeigniter active record Join multiple select statementscodeigniter 活动记录加入多个选择语句
【发布时间】:2014-02-15 03:52:30
【问题描述】:

我在活动记录中找不到像下面的查询那样加入多个选择的任何参考,有人知道这是怎么做的吗?

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

【问题讨论】:

    标签: codeigniter activerecord join


    【解决方案1】:

    你可以把你的 sql 字符串写成这样:

    $this->db->query('YOUR QUERY HERE')
    

    例子:

    $this->db->query('SELECT * FROM tbl_users WHERE age > 18');
    

    【讨论】:

      猜你喜欢
      • 2011-05-07
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2011-09-16
      • 2012-11-05
      相关资源
      最近更新 更多