Reputation: 43
The SQL
statement below returns the right result, however I am having trouble converting this to Laravel
and finding the right way to code Count(*) >=2
.
SELECT `column_id`
FROM `table`
WHERE `game_id`
IN ( 13, 14 )
GROUP BY `column_id`
HAVING COUNT( * ) >=2
Upvotes: 1
Views: 46
Reputation: 4755
Use havingRaw()
DB::table('table')
->select('column_id')
->whereIn('game_id', array(13, 14))
->groupBy('column_id')
->havingRaw('COUNT(*) >=?', array(2))
->get();
Upvotes: 1