如何获取“select count(*)group by”使用laravel雄辩 [英] How do I get a "select count(*) group by" using laravel eloquent
本文介绍了如何获取“select count(*)group by”使用laravel雄辩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用laravel雄辩执行以下句子:
I would like to execute the follow sentence using laravel eloquent
SELECT *, count(*) FROM reserves group by day
我唯一的解决方案是在数据库中创建一个视图,但我确定那里
The only solution occurs to me is to create a view in the DB, but I am pretty sure there is a way to do it in laravel way.
推荐答案
你可以使用这个:
$reserves = DB::table('reserves')->selectRaw('*, count(*)')->groupBy('day');
这篇关于如何获取“select count(*)group by”使用laravel雄辩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文