2

When using in mysql insert..on duplicate, what happens to the rest of the columns that are not being updated? Do they remain the same? I don't want to erase the rest of the data, only need to make sure certain rows are there (and if they are not, then update them).

I believe that I should not be using replace, which does replace the entire row.

See also this question.

Community
  • 1
  • 1
Lucy Weatherford
  • 5,452
  • 16
  • 50
  • 76

1 Answers1

3

Correct. When using INSERT..ON DUPLICATE UPDATE, if the INSERT fails, only the fields explicitly stated in the UPDATE clause are updated. The rest of the fields remain unchanged.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143