选择查询
select sale_id, price,cONVERT(sum(price) , decimal(10,2)) as average, s.total from sale_items i
JOIN sales s ON s.id = i.sale_id
where s.currency = 'USD'
and s.currency_total != 0
and s.`deleted_at` is null
and i.`deleted_at` is null
group by s.id
having s.total <> average;
更新我尝试的查询
UPDATE sale_items i
JOIN sales s ON s.id = i.sale_id
SET i.price=(i.price / (s.total/s.currency_total)), i.total=(i.total / (s.total/s.currency_total)), i.total_tax=(i.total_tax / (s.total/s.currency_total))
where s.currency = 'USD'
and s.currency_total != 0
and s.`deleted_at` is null
and i.`deleted_at` is null
group by s.id
having s.total <> average;
错误:在'group by s.id having s.total<gt;average'附近使用的语法