1

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
2
  • Vote to close because of lack of effort from OP Commented Aug 13, 2014 at 8:23
  • 1
    Thanks for the vote of confidence... It took me three hours to work out how to write the correct SQL query!!!, I could add to the post if you want with all the failed attempts to get this code working in laravel, if you believe it is of use? Commented Aug 13, 2014 at 8:37

1 Answer 1

1

Use havingRaw()

DB::table('table')
->select('column_id')
->whereIn('game_id', array(13, 14))
->groupBy('column_id')
->havingRaw('COUNT(*) >=?', array(2))
->get();
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you ->havingRaw() was what I was looking for :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.