I've been fighting with this for hours now. I need to build a master table from multiple tables (bad design, I know.) I've written this code:
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;
I've made DashboardFirst and DashboardLast a combined key. But whenever I run this, it only inserts, never updates, and I know that some of the records should update.
Any ideas?