Click here to Skip to main content
15,748,049 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
PANDAS DATAFRAME
I have a table that looks like this ... Table (1)

names (INDEX)  ------  ID
DWIGHT S.  ------     56756
JIM H.  ------        32456
KEVIN M.  ------      76765
MICHAEL S.  ------    34245 
PAM B.  ------        84572

I have a "key" that looks like this ... Table (2)

names (INDEX)  ------ FULL NAME
DWIGHT S.  ------     SHRUTE, DWIGHT
JIM H.  ------        HALPERT, JIM
KEVIN M.  ------      MALONE, KEVIN
MICHAEL S.  ------    SCOTT, MICHAEL
PAM B.  ------        BEESLY, PAMELA


I want to have the first table to looks like ...

FULL NAME (INDEX)  ------ ID
SHRUTE, DWIGHT  ------    56756
HALPERT, JIM  ------      32456
MALONE, KEVIN  ------     76765
SCOTT, MICHAEL  ------    34245
BEESLY, PAMELA  ------    84572


What I have tried:

Not sure where to begin ---

Maybe map the values in Table (2) to the index in Table (1)
Posted
Updated 6-Sep-18 12:34pm
v2

1 solution

Execute this query this will update your first table. I believe the Index column in first table is unique.

UPDATE tbl1
SET
tbl1.Index= tbl2.FullName

FROM Table1 tbl1
JOIN Table2 tbl2 ON tbl2.Index= tbl1.Index
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900