Scott Haneda <[EMAIL PROTECTED]> wrote on 12/16/2005 08:46:29 PM: > I need to do this just once... > > I have table zip_codes and table hardiness_zones > In this case, the key will be the actual zip codes. > > hardiness_zones has two fields, zone_start and zone_end, these are all empty > in the zip_codes table. I just need to move the data over, where the zip > codes are ==. > > 4.0.18-standard-log > > UPDATE zip_codes, hardiness_zones > SET zip_codes.zone_start=hardiness_zones.zone_start, > zip_codes.zone_end=hardiness_zones.zone_end; > > Is that correct, and how can I test this before I do the real thing, aside > from working on a copy of the table, is there something where I can run it > and have it not really do anything, kinda like EXPLAIN, but not exactly. > -- > ------------------------------------------------------------- > Scott Haneda Tel: 415.898.2602 > <http://www.newgeo.com> Novato, CA U.S.A. > >
When joining tables, you need to specify the conditions on which the two tables are supposed to match. If you do not, you get a Cartesian product of the two tables. I don't see your matching condition. Here is how I would write it (using an explicit JOIN) UPDATE zip_codes zc INNER JOIN hardiness_zones hz ON hz.zip_code = zc.zipcode SET zc.zone_start = hz.zone_start ,zc.zone_end = hz.zone_end; Shawn Green Database Administrator Unimin Corporation - Spruce Pine