-1

The basic/elemental QUERY is:

SELECT SUM(field) AS AT, `table`.* FROM `table` WHERE id = '1';

I have one table with

field `id` mediumint(8)
field `field` int(12)

in my local MySQL 5.6.27 all run FINE.

in remote MySQL 5.7.28 I get this error:

#1140 - In aggregated query without GROUP BY,
expression #2 of SELECT list contains nonaggregated column
'BD.TABLE.id'; this is incompatible with sql_mode=only_full_group_by

Logically I no want change/modify any in MySQL config.

is possible fix error from QUERY?

thanks

VyR
  • 201
  • 1
  • 2
  • 13
  • 1
    Change `table.*` to `id` and add `GROUP BY id` to the query. It doesn't make sense to try and read `field` when you are summing it. – Nick Nov 10 '19 at 00:38

1 Answers1

0

Thanks {Nick, GMB} by your help. When I change the QUERY to:

SELECT SUM(field) AS AT, `table`.* FROM `table` WHERE id = '1' GROUP BY `table`.`id`;

All run fine.

(only ADD "GROUP BY table.id" resolve the problem)

:-)

VyR
  • 201
  • 1
  • 2
  • 13