Thank you Laserlight and Wycnet for your help, However now I am really confused.. I think I need to explain where I am at in this as my original post was based on using the database tables I had which I think are setup wrong to accomplish what I need to do. At this Point I need to get the Data from the Old into the New.
OLD TABLE THAT I BELIEVE IS NOT CONSTRUCTED CORRECTLY
Surname | Polk | Pasco | Orange | Manatee | Hernando
Smith | 10 | 20 | 3 | 14 | 4
Jones | 4 | 25 | 15 | 18 | 6
Snyder | 10 | 2 | 30 | 17 | 1
Sanchez | 1 | 20 | 3 | 12 | 14
Adams | 1 | 28 | 3 | 1 | 40
Klein | 10 | 40 | 3 | 17 | 3
NEW TABLES:
Surname table
+----+---------+
| id | surname |
+----+---------+
| 1 | Smith |
| 2 | Jones |
| 3 | Snyder |
| 4 | Sanchez |
| 5 | Adams |
| 6 | Klein |
+----+---------+
County table
+----+----------+
| id | name |
+----+----------+
| 1 | Polk |
| 2 | Pasco |
| 3 | Orange |
| 4 | Manatee |
| 5 | Hernando |
+----+----------+
SurnamesPerCounty table
+-----------+------------+-----------+
| county_id | surname_id | frequency |
+-----------+------------+-----------+
| 1 | 1 | 10 |
| 1 | 2 | 4 |
...
I Have ALL Data Entered into the Surname Table and County Table (ass above).
My Challenge Now is to Insert Into the SurnamesPerCounty table The data from the Surname Table, County Table and the Frequencies from my original Table.
So...... I believe what I need to do is somehow..
Select all "surnames" from OLD TABLE
Select all "surnames" from New Surnames Table Where surname = Old Table "surname" and (get ID)
Now This where I Really Get Loss... In the Old Table the Counties are Fields So I guess I need to Somehow..
Select "county" from New County Table Where County Matches the Field Name In OLD Table, Get the ID for the county (from new County Table)
Then get the "frequency" from the OLD Table where the county field = "name" from New County Table, and the "surname" from = "surname"
Then Insert the county_id, surname_id and the frequency into the New SurnamesPerCounty Table.
MAN this seems confusing.. If anyone can give me some code examples of how to accomplish this It would be greatly appreciated.