Question : SQL Query help

Hi,
I'm looking for a SQL query to do the following:

I have a table of People that has a column, Parent, containing a pointer to the row who is the parent.
Unfortunately, instead of pointing to the Primary Key, it points to another column called Index. I want to change the contents of the Parent column to point to the correct Key instead.  Sample input is below, and the table I want to end up with is below that.  

Key      Name      Parent      Index
1      Joe      C      A
2      Jim      A      B
3      Jed      B      C
4      Joy      C      D

Key      Name      Parent      Index
1      Joe      3      A
2      Jim      1      B
3      Jed      2      C
4      Joy      3      D

Don't assume that either the Keys or Index appear sequential like in the example above.
I'm rather new to SQL and cannot figure out how to do it.
Thanks.

Answer : SQL Query help

look at the following sample. it will do exactly what you need
1:
2:
3:
4:
5:
update A set parent =  B.[key]
from people A 
inner join people B
on A.parent = B.[index] 
Random Solutions  
 
programming4us programming4us