INSERT... ON DUPLICATE KEY UPDATE
Hi,
I'm trying to construct the following statement to either update or insert a new record.
I only have one unique field called NAME.
INSERT INTO import_io_mysql (tournament, year, name, thru, total) VALUES ('RBC Heritage','2015', 'Jordan Spieth', '56', '-12') ON DUPLICATE KEY UPDATE (tournament='RBC Heritage', year='2015', name='Jordan Spieth', thru='56', total='-12');
I'm a little bit confused if I need values both before and afer the ON DUPLICATE KEY UPDATE section?
Can someone please clarify what I need. I am hoping to use it with PDO and PHP to give me something like this
INSERT INTO import_io_mysql (tournament, year, name, thru, total) VALUES (:tournament, :year', :name, :thru, :total) ON DUPLICATE KEY UPDATE tournament=:tournament, year=:year, name=:name, thru=:thru, total=:total");