MYSQL error: Column’id’ in field list is ambiguous solution

[Err] 1052 – Column ‘modify_time’ in where clause is ambiguous

Error statement:

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

 

The column’ID’ is repeated in the field list. In fact, the two tables have the same field, but the table name is not added before the name of the table field when used, resulting in unknown reference

 

after adjustment:

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

 

Similar Posts: