I have 2 tables that will match on a value, let's call it PersonID. Here are the tables:
Table1
ID | Field | Value
-----|-----------|--------
1 | Loc1 | faf
1 | Loc1 | 0653
2 | Loc1 | 5711
3 | Loc1 | 9669
4 | Loc1 | ado
4 | Loc1 | 6843
5 | Loc1 | rfc
6 | Loc1 | cba
Table2
ID | Loc1 | Loc2
-----|-----------|--------
1 | faf | 0653
2 | | 5711
3 | | 9669
4 | ado | 6843
5 | rfc |
6 | cba |
I accidentally inserted the value Loc1
for the Field in Table1. I need to update it based on the name of the colomn from Table2.
How can I update Table1 by searching for the Table1.Value column in Table2 and then taking the column name. I need it to end up looking like this:
ID | Field | Value
-----|-----------|--------
1 | Loc1 | faf
1 | Loc2 | 0653
2 | Loc2 | 5711
3 | Loc2 | 9669
4 | Loc1 | ado
4 | Loc2 | 6843
5 | Loc1 | rfc
6 | Loc1 | cba
NOTE: All Loc2 values are not numbers and All Loc1 values are not letters. I just used those values for simplicity sake.