[Today I Learned] Insert and Update rows with MySQL “ON DUPLICATE KEY UPDATE”

You can use MySQL’s “ON DUPLICATE KEY UPDATE” to insert and update rows when your query faces a “Duplicate Key” error.