Title: RE: update query??? HELP!!!

> -----Original Message-----
> From: Janet Linsy [mailto:[EMAIL PROTECTED]]
>
> How to do this query, I have three tables:
> SERVICE_LOCATION a, SERVICE_LOC_AREA b, FRANCHISE_AREA
> c.
>
> The relationship between them is:
> a.SERVICE_LOCATION_ID = b.SERVICE_LOCATION_ID and
> b.FRANCHISE_ID = c.FRANCHISE_ID
>
> I need to update CENTRAL_OFFICE_CODE column  in table
> SERVICE_LOCATION a, using a value selected from
> FRANCHISE_AREA c.  a and c are related through b.
>
> update SERVICE_LOCATION set CENTRAL_OFFICE_CODE =
>       (select FRANCHISE_NAME
>       from  FRANCHISE_AREA)
> where        
> a.SERVICE_LOCATION_ID = b.SERVICE_LOCATION_ID and
> b.FRANCHISE_ID = c.FRANCHISE_ID)
>
> I don't know where to specify a, b, c tables.

I believe this is the statement you want (assuming that onlye one franchise_name will be returned for a particular service_location_id)

update service_location a
set a.central_office_code =
(select c.franchise_name
 from service_loc_area b,
      franchise_area c
  where a.service_location_id = b.service_location_id
        and c.franchise_id = b.franchise_id) ;

Reply via email to