Have the following problem
INSERT INTO statistics_new (SELECT * FROM statistics)
->
-> ON DUPLICATE KEY UPDATE
->
-> end_date = IF(end_date < VALUES(end_date), VALUES(end_date), end_date);
ERROR 1052 (23000): Column 'end_date' in field list is ambiguous
When I tried to specify column and table aliases as it recommended in http://dev.mysql.com/doc/refman/5.0/en/insert-select.html I had the same result.
Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu)
The following query runs without problem :
INSERT INTO statistics_new (SELECT * FROM statistics)
ON DUPLICATE KEY UPDATE
end_date = VALUES(end_date)
SQLFiddle example
Basically I think you want this: