In MySQL INSERT
- REPLACE INTO
- INSERT INTO .. ON DUPLICATE KEY UPDATE
Which SQL is Better? Could you give me a advice?
In MySQL INSERT
Which SQL is Better? Could you give me a advice?
Depends what you're doing with them. REPLACE INTO
is technically faster since it doesn't have to do a read before updating (but that is mostly irrelevant), but I've felt that INSERT INTO ... ON DUPLICATE KEY UPDATE
is generally more clear as to what you want to do.
Here is a short discussion in a blog.