We help IT Professionals succeed at work.
Get Started

Removing duplicates

hazemfadl
hazemfadl asked
on
336 Views
Last Modified: 2012-05-11
Hello,

I have 2 tables:

District:
DistrictID      DistrictName
1                  Cairo
23                Cairo
44                Cairo
60                Alex
62                Alex
70                Aswan
74                Aswan
78                Aswan

Map:
MapID    DistrictID  MapName
1            1               ABC
2            44             XYZ
3            23             DEF
4            60             GHI
5            62             JKL
6            70             MNO
7            74             PQR
8            78             STU

As described above you will note that the MapID (1,2,3) has different ditrictID (and 4,5 and 6,7,8 have the same problem) though they are the same city, I need to do the following:

1- Update the "Maps" table to eliminate the duplicate districtid based on the duplication of the district table (I mean to make all the same district refer to a single DistrictID) -- the maps table have to be as follows:

MapID    DistrictID  MapName
1            1               ABC
2            1             XYZ
3            1             DEF
4            60             GHI
5            60             JKL
6            70             MNO
7            70             PQR
8            70             STU

2- Delete all the duplicates of the District table, districts table have to be as follows:
DistrictID      DistrictName
1                  Cairo
60                Alex
70                Aswan


Any ideas.

Thanks ...
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE