0
我无法理解此重复密钥更新SQL语法。他们都使用非常小的例子。插入...重复密钥更新(PHP:PDO)
我需要去:
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);
我想知道是否有用于更新的快捷方式的所有previouse值提及。或者只是一个更简洁的方式或写作,而不是一个巨大的title =值(标题)列表。例如,我可以(name,team,position,...)=values(name,team,position,...)
吗?
人们总是'REPLACE INTO'如果你打算反正踩的一切。 – tadman 2015-03-13 17:30:44
看到这里以及 - 不是一个重复的问题,但相关:http://stackoverflow.com/questions/11235501/mysql-insert-row-on-duplicate-key-update-multiple-columns – 2015-03-13 17:47:10
不理想,但我认为这是我最好的解决方案。效率会降低,但我更担心这个荒谬的SQL语句。 – Jonathon 2015-03-13 17:50:10