!!!sql_mode=only_full_group_by配置
Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'invoicecertify.goods.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
问题:
select sum(goods.je) je,sum(goods.se) se, goods.hwmc hwmc,goods.zclx zclx ,goods.zcsq zcsq, invoice.state state
,goods.id id,invoice.ref_company_id ref_company_id
from in_goods_detail goods join in_invoice_certification invoice
on invoice.code = goods.code and invoice.number = goods.number
WHERE invoice.cert_state = 3
and (goods.zcsq is null or goods.zcsq = '2017-09')
and ref_company_id = 2107
group by invoice.state,goods.hwmc,goods.zclx,goods.zcsq
测试环境可以用,演示环境不可以用???select version() 不一致,sql_mode 不同
Database changed
mysql>
mysql> set @@GLOBAL.sql_mode='';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> set sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
Query OK, 0 rows affected (0.00 sec)
以下为copy:
mysql命令gruop by报错this is incompatible with sql_mode=only_full_group_by