Performing an UPDATE or INSERT depending whether a row exists or not in MySQL

前端 未结 6 937
小鲜肉
小鲜肉 2020-12-06 14:30

In MySQL, I\'m trying to find an efficient way to perform an UPDATE if a row already exists in a table, or an INSERT if the row doesn\'t exist.

I\'ve found two possi

6条回答
  •  青春惊慌失措
    2020-12-06 15:07

    If you're doing a lot of these, it might be worth writing them to a file, and then using 'LOAD DATA INFILE ... REPLACE ...'

提交回复
热议问题