Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble querying one table for data to be inserted into another table 1

Status
Not open for further replies.

jcaroni

Technical User
Jan 31, 2005
2
US
I have a table full of names and addresses (resource table). In this table I have a field for county (the county the address falls in). I have another table ab_places that contains all the counties associated with every zip code or city and state combo in the country.
I am trying to query the ab_places table to select the correct county to be associated with the address in the resource table and then to update the resource table with the correct counties info.
I am at a loss as to how to do this. Running mysql 4.0.20 so no subqueries.
Any help would be greatly appreciated.
thanks!
- Joey
 
check the manual for the multi-table UPDATE syntax

UPDATE items,month
SET items.price=month.price
WHERE items.id=month.id;

in your case it would be

UPDATE resource,ab_places
SET resource.county=ab_places.county
WHERE resource.something=county.something



rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts March 6 2005)
 
thanks that seems to have done the trick!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top