mysql 5.7.34
一对多
$res=$this->where($where)->field(
'id,client_id,deal_type,product_id,sum(price) total_price,sum(compensate_num) compensate_num_total,sum(compensate_price) compensate_price_total'
)->group('client_id,deal_type,product_id')->select();报错,php7.3倒是没问题,报错说是 group 因id出故障。后来我把 field id去掉就好了。补充错误信息:
[error] [10501]SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'taihao_dd.taihao_compensation_form.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by[/usr/local/nginx/html/taihaotp6/vendor/topthink/think-orm/src/db/PDOConnection.php:795] 最佳答案