Laravel查询构建器中的复杂连接

时间:2015-01-29 09:52:48

标签: php mysql laravel-4 query-builder

我有一个复杂的连接查询,我无法使用Laravel查询构建器创建,

RAW表达式如下:

select r.counted,day (date) as day, month   (date) as month, year   (date) from dates 

left join (select created_at,COUNT(created_at) counted ,day (created_at) as day, month  (created_at) as month, year (created_at) as year from analytics 
where type = 1
and project_id = 1
group by `year`, `month`, `day`
order by `year` desc) r

on `dates`.`date` = DATE_FORMAT(r.created_at, '%Y-%m-%d') 
where `date` between '2015-01-01' and '2015-02-01' 

基本上我希望它能够按天计算所有分析,并获得没有价值的日期

我有模型date和模型analytic analytic已有范围scopeProjectscopeType过滤初始数据

谢谢!

0 个答案:

没有答案