Bulk update relations with query engine updateMany


I would like to do an update of some relations in my table based on matching fields between the two related tables, using either the entity service or the query engine.

Basically, I need the equivalent of the SQL code:

INSERT INTO collectionAs_collectionB_links (collectionA_id, collectionB_id)
SELECT collectionAs.id, collectionBs.id
FROM collectionAs
INNER JOIN collectionBs
ON collectionAs.external_id = collectionBs.external_id;

Is that possible? If not, is there a good workaround?

Thank you!