How to change the values in the table?

How can I change all values US_CITIES.ID_STATE into US_STATES values. STATE_CODE where US_CITIES.ID_STATE is equal to US_STATES.ID?

US_CITIES
ID | ID_STATE | CITY

US_STATES
ID | STATE_CODE | STATE_NAME
March 12th 20 at 07:59
1 answer
March 12th 20 at 08:01
update US_CITIES usc
join US_STATES uss
on usc.ID_STATE = uss.ID
set usc.ID_STATE = uss.STATE_CODE
where usc.ID_STATE = US_STATES.ID

if I understand correctly your logic aydishnikov

Find more questions by tags SQL