大家好,我正在做一个项目,结果发现生产机器上的MySQL版本与我本地的版本不同,这导致了在本地运行的查询导致生产错误。
失败的查询示例如下:
SELECT MONTH(date) month
, YEAR(date) year
, SUM(distinct_totals.total) balance
FROM
( SELECT DISTINCT totals.*
, trans_data.date
FROM totals
JOIN trans_data
ON totals.trans_data_id = trans_data.id
WHERE totals.id IN (1085)
AND trans_data.date BETWEEN '2016-04-05' AND '2017-04-04'
) distinct_totals
GROUP
BY year
, month它在我的本地版本上工作得很好:
Ver 14.14 Distrib 5.7.18但给出了错误:
Mysql2::Error: Unknown column 'totals.*' in 'field list'在版本中:
Ver 14.14 Distrib 5.6.31有没有什么明显的原因,因为版本之间的变化导致了这一点?
发布于 2017-05-23 18:44:25
此错误:
Mysql2::Error:‘字段列表’中的未知列'totals.*‘
暗示着你有
select `totals.*`查询中的某个位置。您需要删除外部反引号或将它们限制为一个标识符:
select `totals`.*
select totals.*https://stackoverflow.com/questions/44131477
复制相似问题