报错信息如下:

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'information_schema.PROFILING.SEQ' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

错误的原因是我mysql版本是5.7的,使用如下语句查询可知

select @@sql_mode;

里面默认设置了

sql_mode=only_full_group_by

only_full_group_by:使用这个就是使用和oracle一样的group 规则, select的列都要在group中,或者本身是聚合列(SUM,AVG,MAX,MIN) 才行,其实这个配置目前个人感觉和distinct差不多的,所以去掉就好

直接修改mysql配置文件(我的系统是Ubuntu16.04的,在/etc/mysql/mysql.conf.d/mysqld.cnf中并没有sql_mode这个配置,所以直接加上就好,如果是其他系统有得修改就不用添加了)

[mysqld]下

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配置文件的完整配置如下:

[mysqld_safe]
socket          = /var/run/mysqld/mysqld.sock
nice            = 0
[mysqld]
# * Basic Settings
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
lower_case_table_names=1
character-set-server=utf8
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address           = 127.0.0.1
# * Fine Tuning
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K

二、不修改配置文件,修改sql写法

在分组时,5.7之前我们会这样写:

SELECT `id` AS `id`,`name` FROM `game` GROUP BY `name`

但是在5.7中,需要使用聚合函数:

SELECT ANY_VALUE(`id`) AS `id`,MAX(`id`),`name` FROM `game` GROUP BY `name`

三、sql_mode解析:

参考自:https://blog.csdn.net/Cooldiok/article/details/59131952

ONLY_FULL_GROUP_BY: 对于GROUP BY聚合操作,如果在SELECT中的列,没有在GROUP
BY中出现,那么这个SQL是不合法的,因为列不在GROUP BY从句中

NO_AUTO_VALUE_ON_ZERO: 该值影响自增长列的插入。默认设置下,插入0或NULL代表生成下一个自增长值。如果用户
希望插入的值为0,而该列又是自增长的,那么这个选项就有用了。

STRICT_TRANS_TABLES: 在该模式下,如果一个值不能插入到一个事务表中,则中断当前的操作,对非事务表不做限制
NO_ZERO_IN_DATE: 在严格模式下,不允许日期和月份为零

NO_ZERO_DATE: 设置该值,mysql数据库不允许插入零日期,插入零日期会抛出错误而不是警告。

ERROR_FOR_DIVISION_BY_ZERO: 在INSERT或UPDATE过程中,如果数据被零除,则产生错误而非警告。如
果未给出该模式,那么数据被零除时MySQL返回NULL

NO_AUTO_CREATE_USER: 禁止GRANT创建密码为空的用户

NO_ENGINE_SUBSTITUTION:
如果需要的存储引擎被禁用或未编译,那么抛出错误。不设置此值时,用默认的存储引擎替代,并抛出一个异常

PIPES_AS_CONCAT:
将”||”视为字符串的连接操作符而非或运算符,这和Oracle数据库是一样的,也和字符串的拼接函数Concat相类似

ANSI_QUOTES: 启用ANSI_QUOTES后,不能用双引号来引用字符串,因为它被解释为识别符

1、在使用groupby查询一张表的数据的时候:selectdate,time,max(delaytime)asdelaytime,sum(delaynum)asdelaynum,max(online... 来自: v587_lu的博客 首先创建数据库hncu,建立stud表格。添加数据:createtablestud(snovarchar(30)notnullprimarykey,snamevarchar(30)notnull,ag... 来自: 谙忆-陈浩翔 1.查看sql_modemysql>showvariableslike"sql_mode";2.复制sql_mode去掉ONLY_FULL_GROUP_BY3.修改m... 来自: Himire的专栏 which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mo 12-09 修改里面的配置文件,sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AU... 来自: longlongxy的专栏 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'xx 在安装mysql5.7.13后,执行SQL语句出现如下情况:----------------------------------------------------------------------... 来自: 李顺生的专栏 which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mod 01-25 错误的原因是我mysql版本是5.7的,使用如下语句查询可知select@@sql_mode; 里面默认设置了sql_mode=only_full_group_byonly_full_group_by... 来自: 酒唸 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo. 11-29 安装了mysql5.7,用groupby查询时抛出如下异常:Expression#3ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedco... 来自: fansili的博客 转载:http://www.jb51.net/article/118538.htmONLY_FULL_GROUP_BY是MySQL提供的一个sql_mode,通过这个sql_mode来提供SQL语句G... 来自: piaoxuan1987 Mysql 升级到 5.7.16,group by 一直报home brew on columns in GROUP BY clause; this is incompatible with sql 12-21 Mysql版本➜/etcmysql-vWelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis3Serverversi... 来自: TryCatch Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'inform 03-20 Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'information_schema.PRO... 来自: 没有用户名的博客 Linux服务器上运行mysqlgroupby查询的时候报错:SELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'wisdom.b... 来自: qq654129588的博客 MySQL5.7版本中GROUPBY,获取最大值问题 新建一个数据表并插入数据CREATETABLE`a`( `id`int(10)unsignedNOTNULLAUTO_INCREMENT, `po... 来自: SFNES的博客 SQL---Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column ' 09-20 数据库中插入数据或执行sql语句时一直报下面这个错误: Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedc... 来自: plpldog的博客 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c 10-08 在my.cnf里面设置sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_... 来自: zhangyong329的博客 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated.. 11-10 [Err]1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'information_... 来自: zq33312757的博客 MySQL: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'sss 03-21 执行MySQL中sql语句的时候报错,执行的sql语句:SELECTprov_desc,area_desc,month_id,MAX(total_fee)ASmax_total,FROMsssWHER... 来自: 康小小的博客 ERROR 1055 (42000): Expression #1 of ORDER BY clause is not in GROUP BY..sql_mode=only_full_group_by 10-19 MySQL错误:Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'DB.table.colum... 来自: Rudon滨海渔村的博客 Expression#1055ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn‘support_desk.mod_users... 来自: qq_40673345的博客 只要执行sql语句,就会抛出错误:Expression#2ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn。。。whichi... 来自: Sonny_w的博客 报错如下:Expression#2ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn‘sss.month_id’whichis... 来自: 海蓝星上 在使用GROUPBY对Mysql的数据表进行查询时如果出现以下错误select*fromusergroupbyage;ERROR1055(42000):Expression#1ofSELECTlist... 来自: 皮蛋瘦肉的博客 mysql遇见Expression#1ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggre的问题http://blog.csdn.net/qq_347... 来自: hq091117的博客 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat 05-29   解决MySQL报错:[Err]1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'... 来自: HaHa_Sir的博客 好郁闷,这句sql看着很正常,可是他就是报错,百度查资料基本都是修mysql的配置文件SELECTitem_idfromtb_order_itemasaa,tb_orderasbbWHEREaa.or... 来自: 码农笔录-微信公众号博客 [Err] 1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated colum 10-25 mysql5.7建表时报错clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by 02-12 mysql5.7数据库在执行建表语句时报错:[Err]1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggrega... 来自: keketrtr的专栏 #1055 - Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this i 09-12 mysql报错#1055-ExpressionofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumnthisisincompati... 来自: MADE_Y Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated 08-30 SQL92及更早版本不允许选择列表,HAVING条件或ORDERBY列表引用在GROUPBY子句中未命名的非分组列的查询。例如,在标准SQL92中,此查询是非法的,因为name选择列表中的未列出的列不... 来自: MissWwg的博客 ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregate 06-12 ERROR1055(42000):Expression#1ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'DBname.t... 来自: Rudon滨海渔村的博客 今天在使用mysql命令行进行分组时报错:ERROR1055(42000):Expression#1ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggr... 来自: 不忘初心的博客 [Err] 1055 - Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated colum 06-04 今天将一个新项目发布到公司的测试环境上,被告知有一个模块报SQL语句的错误,立马在本地环境测试了一下,是正常的,想着奇怪了,然后再把出错的模块打断点截取测试环境出错的SQL语句。语句如下。SELECT... 来自: Static !! Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column '' 10-17 mysql5.7用groupby出现如下报错Expression#1ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedcolumn'xxx... 来自: spirit_8023的博客 MySQL: Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column ' 09-14 http://www.zhimengzhe.com/shujuku/other/252133.html今天在执行MySQL中sql语句的时候报错了,执行的sql语句:SELECTprov_desc,a... 来自: MADE_Y mysql Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column 07-17 setglobalsql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AU... 来自: qq_37080417的博客 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.tdb_ 11-14 原文连接https://www.cnblogs.com/lonelywolfmoutain/p/5433581.html解决办法set@@sql_mode='STRICT_TRANS_TABLES,N... 来自: freehappyness的博客 MySql版本问题sql_mode=only_full_group_by查看sql_modeselect@@sql_mode查询出来的值为:ONLY_FULL_GROUP_BY,STRICT_TRAN... 来自: XiaoMaPro MySQL解决Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column问题 05-31 在使用MySQL进行嵌套查询的时候遇见了错误:MySQL语句:select*,count(id)ascntfrom(select*frommessageorderbycreated_datedesc)... 来自: WilsonSong1024的博客 安装了mysql5.7,用groupby查询时抛出如下异常:Expression#3ofSELECTlistisnotinGROUPBYclauseandcontainsnonaggregatedco... 来自: opfan的博客 [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated 07-06  &a... 来自: innerpeaceScorpio的博客 问题描述:在mysql客户端执行delete删除语句时,报出了以下错误:[Err]1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcont... 来自: pansanday的专栏 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'userinfo 09-21      说明情况:首先我是在Linux服务器上新装了一个mysql,原先版本为5.7.22,现在不小心装成了5.7.16,项目启动是时候跳转首页不显示数据,后台开始报错:     如下,具体错误bu... 来自: weixin_41991232的博客 mysql使用group by分组时出现错误ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and 08-22 使用mysql,groupby分组时出现错误:ERROR1055(42000):Expression#1ofSELECTlistisnotinGROUPBYclauseandcontainsnonag... 来自: antrychme的博客  解决这问题就挺简单的,就是没有权限。 1登陆mysql mysql-uroot-p 2修改权限GRANTALLPRIVILEGESON*.*TO'myuser'@'121.25.33.55'IDEN... 来自: u010785091的博客  java.sql.SQLException:Expression#1ofORDERBYclauseisnotinSELECTlist,referencescolumn'amc.ti.create_t... 来自: 一共丢七只羊的专栏 on columns in GROUP BY clause; this is incompatible wi th sql_mode=only_full_group_by错误 10-02 mysql>selectgoods_id,goods_namefromtdb_goodsgroupbygoods_name;ERROR1055(42000):Expression#1of... 来自: geming2017的博客  SQL:GROUPBYClauseTheGROUPBYclausecanbeusedinaSELECTstatementtocollectdataacrossmultiplerecordsandgr... 来自: 冯立彬的博客 mycat执行报错:java.sql.SQLException: java.lang.IllegalArgumentException: all columns in order by clause 10-24 普通sql语句:SELECTREC_ID,ORDER_UPDATE_RULE,ACTIVITY_IDFROMPLT_ACTIVITY_INFOWHERE((ORDER_GEN_RULE=1ORORDE... 来自: l1994m的博客 解决MySQL5.7报错:[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause ... 01-26  在使用sql语句创建表时,报错:1055-Expression#1ofORDERBYclauseisnotinGROUPBYclauseandcontainsnonaggregatedcolumn‘... 来自: m379373142的博客 对于J2EE项目导入导出Excel是最普通和实用功能,本工具类使用步骤简单,功能强大,只需要对实体类进行简单的注解就能实现导入导出功能,导入导出操作的都是实体对象. 请看一下这个类都有哪些功能: 来自: 李坤 大米时代 第五期 首先吐槽,搞了1天半,终于弄好了。自己android开发是小白,之前一门心思想在jni目录下读取xml文件,事实证明无论如何都不行的。好吧,后来发现资源文件应该都放在assets目录下,可是文件会被压... 来自: Where there is life, there is hope Cholesky分解法又叫平方根法,是求解对称正定线性方程组最常用的方法之一。对于一般矩阵,为了消除LU分 解的局限性和误差的过分积累,采用了选主元的方法,但对于对称正定矩阵而言,选主元是不必要的。 来自: ACdreamer /*==================================================*\ | 3D凸包 | CALL: 构建凸包 = construct(); ... 来自: 南方公园 前面的文章都采用markdown编写的,但编辑图片上极其不方便,以后还是采用网页的形式。 上一篇中讲述了spring boot配置文件的使用,本篇开始从源码的角度来看看配置文件。 环境(En... 来自: liaokailin的专栏 本篇文章是根据我的上篇博客,给出的改进版,由于时间有限,仅做了一个简单的优化。相关文章:将excel导入数据库2018年4月1日,新增下载地址链接:点击打开源码下载地址十分抱歉,这个链接地址没有在这篇... 来自: Lynn_Blog nginx是个好东西,Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambl... 来自: maoyuanming0806的博客 上一期从线程安全的角度聊了聊系统设计要注意的事情,这次换个角度继续聊聊系统设计 这次主题围绕系统设计:有状态、无状态惯例,先看栗子网站登录校验,很普通的一个功能 对于这个功能我们要如何实现?先分析... 来自: Runtime.class 问题场景描述整个项目通过Maven构建,大致结构如下: 核心Spring框架一个module spring-boot-base service和dao一个module server-core 提供系统... 来自: 开发随笔 Class文件的编译过程中不包含传统编译中的连接步骤,一切方法调用在Class文件里面存储的都只是符号引用,而不是方法在实际运行时内存布局中的入口地址。这个特性给Java带来了更强大的动态扩展能力,使... 来自: 兰亭风雨的专栏 更多代码请见:https://github.com/xubo245/SparkLearning 版本:Spark-2.0.01解释 从【2】中下载release版,idea打开mvn packag... 来自: Keep Learning mysql查询报错: ORDER BY clause is not in GROUP BY..this is incompatible with sql_mode=only_full_group_by

阅读数 41290

bootstrap table使用总结

阅读数 40330

php(ThinkPHP)实现微信小程序的登录过程

阅读数 38166

spring配置websocket并实现群发/单独发送消息

阅读数 35480

qq_36821441:[reply]sunboy866[/reply] 我跟你一样 我是protected void service(HttpServletRequest request, HttpServletResponse response, int userid) throws ServletException, IOException。。。。以后直接就response.sendRedirect("xxx.jsp");了 整个界面都没有doGet和super之类的东西

Bot Framework使用Di... y_16041527:请问如何在微信小程序里加入bot