lundi 31 juillet 2017

Syntax error: COLUMN isn't in GROUP BY (SQL, Laravel)

I get an error in Laravel 5.4 trying to run the following query:

    return ReferLinkVisit::where('refer_link_id', $this->id)
        ->groupBy('ipaddr')
        ->get()

Error:

SQLSTATE[42000]: Syntax error or access violation: 1055 'database.refer_link_visits.id' isn't in GROUP BY (SQL: select * from `refer_link_visits` where `refer_link_id` = 1 group by `ipaddr`) (View: /resources/views/dashboard/refer/home.blade.php)

Yet I can run the command in phpmyadmin and it will work just fine. I don't get it because I've wrote similar queries a hundred times but for whatever reason this time it just doesn't want to work. I can't figure out what I've done wrong.

Table structure:

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire