How to do an UPDATE with a JOIN in Drizzle ORM?
Something like this
https://stackoverflow.com/questions/7869592/how-to-do-an-update-join-in-postgresql
I have this schema where I want to do an update on the "user_usage" table, but only if
users.subscriptionId
is a certain string or in a set of string values .
I think what I want here is an UPDATE with a JOIN. Could not quite figure out how to do this with Drizzle ORM.
Something like this from StackOverflow:
But maybe a common table expression (CTE) could work like this example from StackOverflow?
Schema in next postStack Overflow
How to do an update + join in PostgreSQL?
Basically, I want to do this:
update vehicles_vehicle v
join shipments_shipment s on v.shipment_id=s.id
set v.price=s.price_per_vehicle;
I'm pretty sure that would work in MySQL (my backgro...
3 Replies
Schema:
Here is what I'm trying to do as a subquery
You don't need the
.getSQL()
on the subqueryThanks