So I have two tables, one with a key and one with rawdata
Key:
ID | Zone |
---|---|
1 | A |
2 | B |
3 | c |
Raw Data:
ID | DesignatedZone |
---|---|
1 | |
2 | |
2 | |
1 | |
3 |
I want to fill the empty column in rawdata if the value in the ID columns match.
Desired Output:
ID | DesignatedZone |
---|---|
1 | A |
2 | B |
2 | B |
1 | A |
3 | C |
Raw Data has 1000+ rows. Would a JOIN be the best way to tackle it or UPDATE? Im also open to an Excel solution as well since I can edit the data before I import it.
This was my guess:
UPDATE rawdata
SET rawdata.DesignatedZone = key.Zone
WHERE rawdata.ID = key.ID
Use an update join:
UPDATE rawdata r
SET r.DesignatedZone = k.Zone
FROM `Key` k
WHERE k.ID = r.ID;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.