How to update multiple rows with one query?
Take this array as an example:
Is it possible to update all the rows with the new data in one query?
Using plain sql, something like this will be possible:
Thanks for your help!
3 Replies
Btw, this is something which even Prisma doesn’t support yet, but I’m wondering since drizzle is very different in its approach, maybe there’s a better way of doing this (other then writing a raw sql query)..
most orms use CASE WHEN for updating you could investigate that
Thank you, I will check that out!
Although, it’s a bit slow - having to compare each row against all cases. But it’s probably better than making multiple single updates.
Btw, here’s a third approach I stumbled upon, which although it works it made me smile: