我只想问我有这种查询
SELECT id,schedule, COUNT(schedule) as count FROM `games` GROUP BY schedule HAVING count > 1 ORDER BY `count` ASC
但问题是,我不知道如何在laravel查询中使用“HAVING”。
谢谢
答案 0 :(得分:0)
试试这个:
DB::table('games')->groupBy('schedule')->having('count', '>', 1)->orderBy('count', 'asc')->get(['id', 'schedule', DB::raw('COUNT(schedule)')]);