RE: [PHP-DB] duplicate a table

From: Date: Mon, 02 Apr 2001 20:04:43 +0000
Subject: RE: [PHP-DB] duplicate a table
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-8151@lists.php.net to get a copy of this message
And to go one step further with his question, I would like to know how to do the following: 2 tables named table1 and table2 table1 contains 3 records, firstname, lastname, password. table2 is the same except that it has one more field at the beginning and that field is of type serial. Now, I'd like to quickly select * from from table1 and insert it into table2 but each time issuing a nextval('sequence') on each one to update the sequence numbers for table2. This is because I made a bad design decision and decided I needed to have a numerical identifier for each table entry, but the only way I know to do it now would be to manually insert, or to write a php script to do it. I actually did end up doing the php script, but would like to know how else to do it in the future for anything where I'm trying to take the contents of one table and insert it into another table that has a different structure. Thanks a lot. Peace. -----Original Message----- From: McShen [mailto:webmaster@celebritieszones.com] Sent: Monday, April 02, 2001 2:47 PM To: php-db@lists.php.net Subject: [PHP-DB] duplicate a table how do i duplicate a table? i tried create table refer2 select * from refer; create table refer2 as select * from refer; they didn't work. my mysql version is mysql 3.22.28, -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#8151) next »