vendredi 1 avril 2016

Groupby query is not worked in laravel query builder

I am using below query ,

$data = DB::table('developers')
->select('iDeveloperId', 'vFirstName', 'vLastName', 'iGroupId')
->groupBy('vFirstName')
->get();

But i am getting an error like

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

what the mistake i have done.

Note : it works when 'iDeveloperId' is used in the place of 'vFirstName'

Thanks in advance.....



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire