I have 3 tables: SITES, DEVICES AND LOADS.
- SITES columns are (ID, default_MGR_ID);
- DEVICES columns are (ID, site_id (which is the foreign key of sites))
- LOADS columns are (ID, device_id (foreign key of devices), site_mgr_id)
I want to update LOADS.site_mgr_id to be equal to SITES.default_mgr_id.
Can you help me write a SQL query to do that?
This is the query I have so far but is not working:
UPDATE loads SET loads.site_mgr_id =(SELECT default_site_mgr_id FROM sites s WHERE s.id =(SELECT site_id FROM devices d WHERE d.id = loads.device_id)