我已经和这个斗争了好几个小时了。我需要从多个表构建一个主表(糟糕的设计,我知道。)我写了这段代码:
INSERT INTO amdashboard
(DashboardFirst, DashboardLast, charlotteorg, charlotteAdd1, charlotteCity, charlotteState, charlotteZip, charlottey2007, charlottey2008, charlottey2009,charlottey2010, charlotteY2011, charlotteY2012)
select Firstname, lastname, org, add1, city, state, zip, y2007, y2008, y2009, y2010, y2011, y2012
from CharlotteClean
ON DUPLICATE KEY UPDATE
amdashboard.DashboardFirst = CharlotteClean.Firstname,
amdashboard.DashboardLast = CharlotteClean.Lastname,
amdashboard.Charlotteorg = CharlotteClean.org,
amdashboard.Charlotteadd1 = CharlotteClean.add1,
amdashboard.Charlottecity = CharlotteClean.city,
amdashboard.Charlottestate = CharlotteClean.state,
amdashboard.Charlottezip = CharlotteClean.zip,
amdashboard.Charlottey2007 = CharlotteClean.y2007,
amdashboard.Charlottey2008 = CharlotteClean.y2008,
amdashboard.Charlottey2009 = CharlotteClean.y2009,
amdashboard.Charlottey2010 = CharlotteClean.y2010,
amdashboard.Charlottey2011 = CharlotteClean.y2011,
amdashboard.Charlottey2012 = CharlotteClean.y2012;
我已将 DashboardFirst 和 DashboardLast 设为组合键。但是每当我运行它时,它只会插入,从不更新,而且我知道一些记录应该更新。
有任何想法吗?