0

i get this error when i upload it on online cpanel

Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'dreamsch_school_management.students.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by (SQL: select class, count(*) as total from students group by class order by id asc)

in controller i Used

        $groups = DB::table('students')
            ->select('class', DB::raw('count(*) as total'))
            ->groupBy('class')
            ->orderBy('id', 'ASC')
            ->get();

i want to arrange in assending order by class. in bar chart. but it give error in order by line but correctly runs in my localhost. can you please help me with the query. It was my expectation It was my expectation

but without ordering i get this one without ordering

Please see the labels in the pictures then you can get the errors. now I want to know how can I place ordering by ID or class when I upload my project in cpanel.

imvain2
  • 15,480
  • 1
  • 16
  • 21
tariqul anik
  • 314
  • 6
  • 24
  • I think there is no business with javascript here. Please remove the `javascript` tag. – Sajeeb Ahamed May 08 '20 at 20:43
  • removed........ – tariqul anik May 08 '20 at 20:49
  • Does this answer your question? [Error related to only\_full\_group\_by when executing a query in MySql](https://stackoverflow.com/questions/34115174/error-related-to-only-full-group-by-when-executing-a-query-in-mysql) – imvain2 May 08 '20 at 20:49
  • no Brother. my problems are related on laravel query-builder. not with the my sql. thanks for your comments – tariqul anik May 08 '20 at 20:53
  • as it is stated in the error `ORDER BY clause is not in GROUP BY clause and contains nonaggregated column` - you need to change `->orderBy('id', 'ASC')` to `->orderBy('class', 'ASC')` – Ersoy May 08 '20 at 21:21
  • hi bro you are saying that in localhost runs correctly so maybe in your server the mysql you have 'strict' => true, database config and in your localhost you have 'strict' => false. – Alex Guerrero May 08 '20 at 21:29

1 Answers1

1

you have to disabled strict mode in your mysql server just put 'strict' => false in your config/database in the server

Alex Guerrero
  • 229
  • 2
  • 8