2017-06-29 1 views
0

Ich habe die folgende Abfrage:MySQL-Abfrage läuft in phpMyAdmin, nicht in Laravel

SELECT a.*, Count(b.status) as counttotal 
FROM holidays a LEFT JOIN attendances b 
on a.month_id=b.month_id 
GROUP BY a.month_id 

Diese Abfrage führt erfolgreich in phpMyAdmin.

phpMyAdmin screenshot here

Als ich versuchte, die gleiche Abfrage durch php artisan tinker zu laufen, ich folgende Fehlermeldung erhalten:

Illuminate\Database\QueryException with message 'SQLSTATE[42000]: Syntax error or access violation: 1055 'school_blog.a.month' isn't in GROUP BY (SQL: SELECT a.*, Count(b.status) as counttotal FROM holidays a LEFT JOIN attendances b on a.month_id=b.month_id GROUP BY a.month_id)'

Wie behebe ich das?

check the screen shot of erroe msg

+1

[Dies] (https://stackoverflow.com/a/42747612/899126) kann Ihr Problem lösen –

Antwort

2

Gehen Sie zu Ihrer config/database.php und ändern Sie die folgende "true" auf "false", so dass es aussieht wie unten

'mysql' => [ 

    'strict' => false, 

] 
+0

Vielen Dank, es funktioniert jetzt. –

+0

bitte als akzeptiert markieren – ATechGuy