You can use a raw expression:
TableA::join('table_b', 'table_b.id', '=', 'table_a. product_id')
->update(['table_a. propInTableA' => DB::raw('table_b.propInTableB * 100')]);
(Untested, but it should work)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a working SQL query that I can't translate into a Eloquent Expression :
UPDATE
tableA
SET
propInTableA = tableB.propInTableB * 100
FROM
tableB
WHERE
tableA.product_id = tableB.id
Right now, I made it work by wrapping the request within a DB::update() statement, but was wondering if I could use a more expressive Eloquent syntax (with something like TableA::update(...)
To explain, what this query is doing, is updating a property in table1 from a value in tableB.
They key is the FROM clause that is required to make it work, which I'm having a hard time transcribing in Eloquent (using ->from won't work as it will build a query that won't have any sense)
PS: This is the post that helped me figured how to actually do this kind of thing in pure SQL : https://www.postgresqltutorial.com/postgresql-update-join/
Please or to participate in this conversation.