MySql 8 - How to use onDuplicateKeyUpdate with array?
as the title says, how do i use onDuplicateKeyUpdate with arrays? I can pass an array to .values() function but after that i have no idea how to handle duplicate. Help would be appriciated. thanks
3 Replies
Can you show what you're trying to write in SQL?
I figured it out I think. I just start a transaction and map over the array and if there is duplicate then its easy to update that way
You probably don’t want to do that, as it means executing a new query per item in your array, which gets more problematic the bigger it gets
If you’re looking to get access to a value you passed to the initial insert call, you can reference it like