i currently have a database that someone else created a while ago and i have been tasked with speeding up the data entry and search functionality. currently the database is one table with the following field names:

bid_id = primary key
date_num = date of project
proj_nm = name of project
location_nm = location of project
company_nm = name of company involved
amount_num = amount of bid

now being that a number of these projects are done in the same location or being bid for the same companies i have created seperate tables for the location and company fields.

the new tables for those to fields include just a key and a name.

what i am looking to do is go through the current primary table and replace the records in the location and company fields with the primary key from the corresponding table. i would like to find a way to automate this considering the number of records involved not to mention it would be handy to know anyway. so any and all help is greatly appreciated!!

9 Years
Discussion Span
Last Post by trudge

Assuming you are talking about a MySQL database, have you looked at UPDATE / SET?

For example:

UPDATE your.table 
SET your.field = new.value
WHERE your.field = old.value
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.