mysql数据库,select的字段没有全部写在group by里面,为什么这种sql语句还可以执行成功? 可能mysql版本是5.7以下,或者sql_mode是宽松模式,关闭了ONLY_FULL_GROUP_BY设置, 可通过select @@GLOBAL.sql_mode;查看。mysql 特有的不标准语法,尽量避免。其他的像 oracle、SQL Server 不行。
MySQL 5.7 对比 5.6 有很多的变化。一个常见的需求:按条件分组后,取出每组中某字段最大值的那条...
nonaggregated column ‘sss.month_id’ which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 因为不让你group by,所以你得在mysql里这样 1. select @@global.sql_mode 1.set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_...
对于GROUP BY 聚合操作,如果在 SELECT 中的列,没有在 GROUP BY 中出现,那么这个 SQL 是不合法的,因为列不在 GROUP BY 从句中 NO_AUTO_VALUE_ON_ZERO 该值影响自增长列的插入。默认设置下,插入 0 或 NULL 代表生成下一个自增长值。如果用户希望插入的值为 0,而该列又是自增长的,那么这个选项就有用了。
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'mugua.goods.goods_name' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by ...
SELECT列表的表达式#1不在GROUP BY子句中,并且包含未聚合的列'returntr_prod.tbl_customer_pod_uploads...
Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'test.w...
对于GROUP BY 聚合操作,如果在 SELECT 中的列、HAVING 或者 ORDER BY 子句的列,没有在GROUP BY中出现,那么这个SQL是不合法的 ANSI_QUOTES 启用ANSI_QUOTES 后,不能用双引号来引用字符串,因为它被解释为识别符,作用与 ` 一样。设置它以后,update t set f1="" …,会报 Unknown column ‘’ in field list...
SELECT id, name, count(*) AS cnt FROM case_table GROUP BY name 报错,如下: 服务器内部错误 (1055, "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'case_table.id' which is not functionally dependent on columns in GROUP BY clause; this is incompati...
list is not in GROUP BY clause and contains nonaggregated column'jm.books.jb'which is not ...