Subquery with update Laravel eloquent

Viewed 28

I write simple query in Postgres

update target_table t
set sort_no = sort_dtl.new_sort_no
from (select sort_no,row_number() over(order by new_sort_key) as new_sort_no
      from target_table
      where t_no = 123
) as sort_dtl
where t.t_no = 123
and t.sort_no = sort_dtl.sort_no

I want to implement the same thing using Laravel eloquent. How can I do that?

1 Answers
Related