1、问题:
查询语句:
select count(support) supportCount,count(collection) collectionCount, support,collection
from like_collect where articleId = 2;(注意:此处未使用group by语句声明非聚集函数列)
报错描述:In aggregated query without GROUP BY, expression #3 of SELECT list contains nonaggregated column 'pet.like_collect.support'; this is incompatible with sql_mode=only_full_group_by
2、分析报错原因:
mysql的sql_mode默认开启了only_full_group_by 模式
3、解决方法:
把SQL语句中非聚集函数列再group by后声明即可
select count(support) supportCount,count(collection) collectionCount, support,collection
from like_collect where articleId = 2 GROUP BY support,collection;