[Err] 1052 - Column 'modify_time' in where clause is ambiguous
出错的语句:
SELECT AVG(T.se)%60
FROM
( SELECT TIMESTAMPDIFF(SECOND,first_transfer_time,modify_time) se
FROM xes_appeals
INNER JOIN xes_appeal_templates
WHERE xes_appeals.app_type = xes_appeal_templates.app_type
AND xes_appeals.app_type = 313
AND xes_appeals.first_transfer_time >= '2018-11-23 00:00:00'
AND xes_appeals.first_transfer_time <= '2018-11-23 23:59:59'
AND modify_time >= '2018-11-23 00:00:00'
AND modify_time <= '2018-11-23 23:59:59'
AND xes_appeals.`status` =4
AND xes_appeals.operater_id <> 0
) T
列'ID'在字段列表中重复,其实就是两张表有相同的字段,但是使用时表字段的名称前没有加表名,导致指代不明
调整后的:
SELECT AVG(T.se)%60
FROM
( SELECT TIMESTAMPDIFF(SECOND,first_transfer_time,xes_appeals.modify_time) se
FROM xes_appeals
INNER JOIN xes_appeal_templates
WHERE xes_appeals.app_type = xes_appeal_templates.app_type
AND xes_appeals.app_type = 313
AND xes_appeals.first_transfer_time >= '2018-11-23 00:00:00'
AND xes_appeals.first_transfer_time <= '2018-11-23 23:59:59'
AND xes_appeals.modify_time >= '2018-11-23 00:00:00'
AND modify_time <= '2018-11-23 23:59:59'
AND xes_appeals.`status` =4
AND xes_appeals.operater_id <> 0
) T