Is there a fancy way to do mass updates, like mass inserts?
Probably the easiest to implement.
https://dev.mysql.com/doc/refman/8.0/en/insert-on-duplicate.html
1 Like
Thanks, didn’t notice that. Will give it a try.
1 Like
If you use PostgreSQL, you can use a FROM clause subquery composed of a bunch of unioned constant SELECTs. Something like this:
Update myTable Set col_a = subq.a, col_b = subq.b
From (Select ? as a, ? as b, ? as c
Union All Select ?, ?, ?
Union All Select ?, ?, ?
Union All Select ?, ?, ?
Union All Select ?, ?, ?
Union All Select ?, ?, ?) subq
Where myTable.col_c = subq.c
You might need casts after the question marks on the first Select to set the column types.
MariaDB appears to allow a sub-queries in its multi-table form of Update, but I haven’t worked with that.