I made a long query then grouped it with three fields and there are multiple select queries in the alias.

But then I found an error, it didn't take long for me to find the solution.


Solution 1

It's pretty easy just need to run a settings query to group the data


SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
SET SESSION sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Solution 2


If you use phpmyadmin select the variable menu then search for 'sql mode' delete the word only_full_group_by then save.
Or you can do it manually if you use linux.
run this command
sudo nano /etc/mysql/my.cnf
then enter the script below
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

or
sql_mode = NO_ZERO_IN_DATE,NO_ZERO_DATE,NO_ENGINE_SUBSTITUTION
then save by pressing ctrl+o and ctrl+x. Don't forget to restart the database

sudo service mysql restart
run the query again, it should be normal now