Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

Update sql statement for secondary table

SOLVED
Go to solution
Ratzie
Super Advisor

Update sql statement for secondary table

I have a two tables both linked by master_key, I need to update the secondary table based on criteria, I have been able to do the select statement but do not know how to do the update.

select mlr.tn, mlr_cable.CA
from mlr, mlr_cable
where mlr.bld ='VSSR'
and mlr.MASTER_KEY = mlr_cable.master_key
and mlr_cable.ca = '1103'

I need to update the cable to 11 where the cable = 1103 and bld = VSSR and master_key from primary table = master_key from secondary table
2 REPLIES
Jonathan Fife
Honored Contributor
Solution

Re: Update sql statement for secondary table

Use a subselect:

Update mlr_cable set ca = '11'
where ca = '1103' and master_key in (
select master_key from mlr where bld = 'VSSR')

Decay is inherent in all compounded things. Strive on with diligence
Ratzie
Super Advisor

Re: Update sql statement for secondary table

Thanks