I dont want to believe there is a bug in laravel 5.5 cos i am amazed how i keep getting errors on the Eloquent Query Builder when ever i use the groupBy in my query.
Tried converting this SQL that works seamlessly to Eloquent and i keep getting Errors on the groupBy..
Had a similar issue with an SQL which i complained here and till now i have not gotten a perfect answer for it open issue here
SELECT * FROM arm_articles
INNER JOIN arm_interest ON arm_articles.article_category = arm_interest.category_id
WHERE arm_articles.article_contributor_id='1322'
GROUP BY arm_articles.article_id
ELOQUENT VERSION THAT RETURNS ERROR
$contributor_id =1322;
DB::table('arm_articles')
->join('arm_interest', function($join) {
$join->on('arm_articles.article_category','=','arm_interest.category_id');
})
->having('arm_articles.article_contributor_id', '=', $contributor_id)
->groupBy('arm_articles.article_id')->get()
ERROR MESSAGE
SQLSTATE[42000]: Syntax error or access violation: 1055 'knowledge_db.arm_articles.id' isn't in GROUP BY (SQL: select * from 'arm_articles' inner join 'arm_interest' on 'arm_articles'.'article_category' = 'arm_interest'.'category_id' group by 'arm_articles'.'article_id' having 'arm_articles'.'article_contributor_id' = 1322)
So like i said b4 its really weared why i will get the error in the first place as adding ->toSql
to the query returns the right SQL.