Oracle > SQL Samples articles: • Updating fields from one table to another using a join
|
Return to index of articles
Updating fields from one table to another using a join
Category: Oracle
Category: SQL Samples
This joins LST_SITES, LST_CITIES AND LST_REGIONS TO GET THE REGION_ID FROM LST_REGIONS AND PUT IT IN LST_SITES (SO EACH SITE HAS A REGION IN IT)
update LST_SITES L
SET REGION_ID =
(
select REGION_ID FROM
(
(
LST_SITES LL LEFT JOIN LST_CITIES T
ON
LL.CITY=T.CITYCODE
)
LEFT JOIN
LST_REGIONS ON
LST_REGIONS.REGION_ID = T.REGIONCODE
)
WHERE L.SITE_ID=LL.SITE_ID
);
9/9/2003
|