Some time you want to update a column in a table from another table’s column and in magento 2 you can use “updateFromSelect” function to do it.
- This is an example in resouce model
- And this is the query after the code is render
UPDATE `maintable` AS `maintable`
INNER JOIN `maintable`
LEFT JOIN `'join_table'` AS `'join_table'` ON main_table.id = 'join_table'.id
SET `'main_table'`.`name` = `'join_table'`.`name`
Hope it helpful for you.
The steps I mention above is the shortest process for you to Update a Column in a Table from Another Table’s Column in Magento 2.
Thank you for reading this post and see you in other posts from Magestore!
We also contribute great content of Magento Download for FREE (all versions)
DON'T MISS THE CHANCE!