Я использую запрос ниже:
$data = DB::table('developers')
->select('iDeveloperId', 'vFirstName', 'vLastName', 'iGroupId')
->groupBy('vFirstName')
->get();
Но я получаю сообщение об ошибке:
Warning: Creating default object from empty value in /var/www/html/laravel_demo/query_builder/db_config.php on line 40
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'hbmp_hims.developers.iDeveloperId' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by' in /var/www/html/laravel_demo/query_builder/illuminate/vendor/illuminate/database/Connection.php:333 Stack trace: #0 /var/www/html/laravel_demo/query_builder/illuminate/vendor/illuminate/database/Connection.php(333): PDO->prepare('select `iDevelo...') #1 /var/www/html/laravel_demo/query_builder/illuminate/vendor/illuminate/database/Connection.php(662): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'select `iDevelo...', Array) #2 /var/www/html/laravel_demo/query_builder/illuminate/vendor/illuminate/database/Connection.php(629): Illuminate\Database\Connection->runQueryCallback('select `iDevelo...', Array, O in /var/www/html/laravel_demo/query_builder/illuminate/vendor/illuminate/database/Connection.php on line 669
Какую ошибку я сделал.
Примечание: это работает, когда iDeveloperId
используется вместо vFirstName
Заранее спасибо …
Попробуй отключить Full group by
в вашей базе данных MySQL.
SET sql_mode = ''
Я получил ответ
SET GLOBAL sql_mode = '';