大家好,我需要帮助在Code Igniter上编写子查询,如果我使用db active record,我总是会失败。
我想要运行的查询是
select ( alias_a.field_a + alias_b.field_b ) as total_a from
( select sum(field_a) as TOTAL_SUM, status, date from table_a
where status ='ok'
group by year(date)) as alias_a ,
(select sum(field_b) as total_b, status, date from
table_b where
status = 'good' group by year(date)) as alias_b
where year(alias_a.date) = year(alias_b.date)
此查询已在sql编辑器上运行
我试过了$this->db->query('my query')
,但它有错误
任何信息都会对我有所帮助。 谢谢 ! :)
答案 0 :(得分:-1)
嗨,请检查CI中的引号。 您是否可以发布在CI查询中实现的确切代码,以便我们可以看到问题。
谢谢(=