From: Christian Mack Date: March 30 1999 10:35am Subject: Re: Copying records from a table and re-inserting them List-Archive: http://lists.mysql.com/mysql/1177 Message-Id: <3700A8FE.58697FC2@compal.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mike Watson wrote: > > I'm using Perl DBI to manage a set of MySQL tables. I want to copy a set of > records from a table and re-insert them with a new radio station id. > Selecting the set of records is no problem, but there is no equivalent of > the SELECT * for the insert command (INSERT INTO *). What I have done is > used show columns to get a list of field names and from this built a string > for the insert command. I don't want to change any timestamp values, which I > don't because I reference those fields in the insert string. I have had to > look at field types and escape special chars in text fields. Now I have hit > another wrinkle. We use a seperate id field as a primary key so I don't want > to insert this value, I want the data base automatically pick a value for > this field. Again, I can do this. > > Is there an easier way? > > Thanks > > Michael Watson Hi Michael You can do this with plain SQL. Use: INSERT INTO tableName SELECT field1,field2,'newRadioStation',field4,NULL,field6 ... Hint: INSERT INTO tableName VALUES (...) Is what you call a INSERT INTO tableName * VALUES (...). Be sure to use the correct data sequence. Tschau Christian