AM using MySQL 5.7.13 on my windows PC with WAMP Server
Here my Problem is While executing this query
SELECT *
FROM `tbl_customer_pod_uploads`
WHERE
You can disable sql_mode=only_full_group_by by some command you can try this by terminal or MySql IDE
mysql> set global sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
mysql> set session sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
From how it looks, I think grouping by multiple columns/fields wont hurt your result. Why don't you try adding to the group by like this:
GROUP BY `proof_type`, `id`
This will group by proof_type
first then id
. I hope this does not alter the results. In some/most cases group by multiple columns gives wrong results.
Here is a really fast and easy way of setting it permanently
NB: running SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
is temporary and on server restart you will still end up with the error.
To fix this permanently do the below
wget https://gist.githubusercontent.com/nfourtythree/90fb8ef5eeafdf478f522720314c60bd/raw/disable-strict-mode.sh
chmod +x disable-strict-mode.sh
./disable-strict-mode.sh
And your done , changes will be made to mysql and it will be restarted
This
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'returntr_prod.tbl_customer_pod_uploads.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
will be simply solved by changing the sql mode in MySQL by this command,
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
This too works for me.. I used this, because in my project there are many Queries like this so I just changed this sql mode to only_full_group_by
Thank You... :-)
Hi instead of taking all columns, just take what you need by using ANY_VALUE(column_name)
. It is working perfectly. Just check.
E.g.:
SELECT proof_type,any_value("customer_name") as customer_name
FROM `tbl_customer_pod_uploads`
WHERE `load_id` = '78' AND `status` = 'Active' GROUP BY `proof_type`
That's all.
I did this in my Ec2 and it worked like charm.