mysql錯誤:Column ‘id’ in field list is ambiguous的解決方法

[Err] 1052 - Column 'modify_time' in where clause is ambiguousapp

出錯的語句:im

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

) Tdi

 

列'ID'在字段列表中重複,其實就是兩張表有相同的字段,可是使用時表字段的名稱前沒有加表名,致使指代不明time

 

調整後的:opera

SELECT AVG(T.se)%60FROM( 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

相關文章
相關標籤/搜索