0
下面我粘贴了mysql查询。请帮助我将此查询转换为laravel 5.如何将mysql查询转换为laravel 5?
select
t.username,
sum(case when t.status_id = 1 then t.count else 0 end) as status_1,
sum(case when t.status_id = 0 then t.count else 0 end) as status_0,
sum(case when t.status_id = 0 and t.status_desc = 2 then t.count else 0 end)
as status_0_2,
sum(case when t.status_id = 0 and t.status_desc = 3 then t.count else 0 end)
as status_0_3
from (
select username, status_id, status_desc, count(status_desc) as count
from log
group by username, status_id, status_desc
) as t
group by t.username;
为什么要将其转换为Laravel的方案?只需创建一个视图,并与口才...... –
我的项目在laravel我的工作进行查询,和我在MySQL的解决方案,但我没有对自己在使用laravel情况下任何想法。这就是为什么。\ –
好吧,那么有道理。转换它祝你好运!我相信给出的答案可以满足你的需求,你试过了吗? –