Updating table with data from another table in the same database

From: Date: Wed, 09 Jan 2002 14:36:34 +0000
Subject: Updating table with data from another table in the same database
Groups: php.db 
Request: Send a blank email to php-db+get-15560@lists.php.net to get a copy of this message
Hello, all! I have the daunting task of porting an Access database to MySQL. It's unbeliveably poorly designed, and columns id, name, issn, year, info, volume, numbers and remarks. I made another table, names, that's got columns id and name. I used INSERT INTO names (name) SELECT DISTINCT mag_table.name FROM mag_table to get, as one would expect, the distinct magazine names into the names- table. Now, what I'd want to do, is to replace the names in mag_table with the id-numbers from the names table, but I can't figure out how to do it. I tried UPDATE mag_table SET name=names.id WHERE name=names.name but MySQL tells me the following : ERROR 1109: Unknown table 'names' in where clause I haven't go perror to work at all, it just says Unknown error. Has anyone ever done anything like this, and, if so, how? I was thinking about a PHP-script, but if someone has got a query that would take care of this I wouldn't have to get into that. Cheers, Markus -- Markus Lervik Linux-administrator with a kungfoo grip Vaasa City Library - Regional Library markus.lervik@vaasa.fi +358-6-325 3589 / +358-40-832 6709

« previous php.db (#15560) next »