Laravel自定义原始查询

时间:2015-03-09 08:23:42

标签: php laravel

我只想问我有这种查询

SELECT id,schedule, COUNT(schedule) as count FROM `games` GROUP BY schedule HAVING count > 1 ORDER BY `count` ASC

但问题是,我不知道如何在laravel查询中使用“HAVING”。

谢谢

1 个答案:

答案 0 :(得分:0)

试试这个:

DB::table('games')->groupBy('schedule')->having('count', '>', 1)->orderBy('count', 'asc')->get(['id', 'schedule', DB::raw('COUNT(schedule)')]);