我正在使用以下查询:
$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
时,它有效
提前致谢...
答案 0 :(得分:3)
尝试在MySQL数据库中禁用Full group by
。
SET sql_mode = ''
答案 1 :(得分:0)
我得到了答案
SET GLOBAL sql_mode = '';