3
I installed mysql in my note and am using Linux Mint 18.2. When I run the query:
SELECT *,SUM(ValorTotalProdutos) AS ValorTotal, SUM(QtdProdutos) AS QtdFinal FROM tabela WHERE SESSIONID = '77c2c1de02e94581a459ed2d4fa76370' AND StatusCompras = 'A'
Error appears:
#1140 - In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'banco.tabela.IDCarrinho'; this is incompatible with sql_mode=only_full_group_by
I opened the file my.cnf
sudo nano /etc/mysql/my.cnf
And include at the end of the file:
sql-mode=""
I restarted mysql:
sudo service mysql restart
It was a mistake. Then I deleted the above command and included another line:
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
I restarted and the same error appeared. The error that appeared in both is:
sudo service mysql restart
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
How do I disable sql-mode?
Obrigado Bacco.
– user24136
@Did Fox.11 make out with any of the options? I suggest you rethink the query so your script stays portable on other servers, unless you’re sure you’ll always have control over the environment
– Bacco
Hello Bacco. I have chosen to place Group By at the end of the query. Thank you.
– user24136