I am having trouble understanding this ON DUPLICATE KEY UPDATE sql syntax. They all use very small examples.
Do I need to go:
INSERT INTO skaters (id,name,team,position,games_played,goals,assists,points,plus_minus,penalty_minutes,power_play_goals,power_play_points,shorthand_goals,shorthand_points,winning_goals,overtime_goals,shots,shot_percentage,time_on_ice_pg,faceoff_win_percentage) VALUES (:id,:name,:team,:position,:games_played,:goals,:assists,:points,:plus_minus,:penalty_minutes,:power_play_goals,:power_play_points,:shorthand_goals,:shorthand_points,:winning_goals,:overtime_goals,:shots,:shot_percentage,:time_on_ice_pg,:faceoff_win_percentage)
ON DUPLICATE KEY UPDATE name=values(name),team=values(team),position=values(position),games_played=values(games_played),goals=values(goals),assists=values(assists),points=values(points),plus_minus=values(plus_minus),penalty_minutes=values(penalty_minutes),power_play_goals=values(power_play_goals),power_play_points=values(power_play_points),shorthand_goals=values(shorthand_goals),shorthand_points=values(shorthand_points),winning_goals=values(winning_goals),overtime_goals=values(overtime_goals),shots=values(shots),shot_percentage=values(shot_percentage),time_on_ice_pg=values(time_on_ice_pg),faceoff_win_percentage=values(faceoff_win_percentage);
I was wondering if there was a shortcut for update all the previouse values mentioned. Or just a more concise way or writing instead of a huge list of title=values(title). Can I (name,team,position,...)=values(name,team,position,...) for example?
REPLACE INTOif you're going to stomp everything anyway.unique. IT is based on pre-existing ids so is notauto_increment. Updated code to exactly what I have used and tested with (it does indeed work).