[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'informat
[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c
转载WxyangID 发布于2018-05-11 19:11:43 阅读数 2486 收藏
在navicat for mysql中的查询编辑器中执行sql语句总是提示下面的错误,虽然也可以正确的执行,但是看着总有些不对劲,所以就在csdn上查找了解决方案:已验证此解法可以有效。
解决方法:
主要是因为sql_mode设置导致的这个错误。
在新建查询中执行如下命令:
-
-- 查看sql_mode设置
-
show variables like "sql_mode";
-
-- 设置sql_mode
-
set sql_mode='';
-
set sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
结果证明该方案有效;
也可以参考博主的另一个方法,设置mysql中的my.ini文件。
参考:https://blog.csdn.net/zq33312757/article/details/53118459
*******************************************************************************************************************
选中数据库
-- 查看sql_mode设置
show variables like "sql_mode";
-- 设置sql_mode
set sql_mode='';
set sql_mode='NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES';
create table `product_info`(
`product_id` varchar(32) not null comment '商品id',
`product_name` varchar(64) not null comment '商品名称',
`product_price` decimal(8,2) not null comment '单价',
`product_stock` int not null comment '库存',
`procuct_description` varchar(64) comment '描述',
`product_icon` varchar(512) comment '小图',
`procuct_type` int not null comment '类目编号',
`create_time` timestamp not null default current_timestamp comment '创建时间',
primary key (`product_id`) # 这里不是单引号怪不得写不出来 报错
)comment '商品表'