'ORACLE SQL updating left table from right table using bridge table
This is a why-oh-why moment for me. I have a many-to-many relationship between tables A and B. Two columns in A need to be updated with two columns from B based on where the IDs match in bridge table C.
Any help is greatly appreciated.
Every script I've tried throws an error "single row query returns multiple rows".
Desired result is Reports.BU, Reports.AA = Assets.BU, Assets.AA where they match in Bridge. This is as far as I've gotten at this point.
UPDATE Reports
SET (BU, AA) = (SELECT BU, AA
FROM (SELECT Bridge.Report.report_id,
Bridge.asset_id,
Assets.BU,
Assets.AA,
MAX(Bridge.asset_id)
FROM Bridge
JOIN Asset
ON Asset.asset_id = Bridge.asset_id
group by bridge.report_id,
Bridge.asset_id,
Asset.BU,
Asset.AA)
WHERE report_id = Reports.report_id);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

