Re: Subject: Retrieve data, add new fields and enter it in new ta

From: Date: Tue, 22 Jun 2004 08:01:03 +0000
Subject: Re: Subject: Retrieve data, add new fields and enter it in new ta
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-34858@lists.php.net to get a copy of this message
Look at the INSERT... SELECT syntax in the MySQL manual Basically you can do this but only between 2 different tables (which is what you specified) : Generate and *test* the SELECT statement you want to use to recover your data set. Then in PHP try a query like this : $query="INSERT INTO table2 ( id, name, address1, address2, address3, password )
        SELECT id, name, address1, address2, address3, ' ".$your_password_key." '
        FROM table1";
So here you have selected the 4 fields form table 1 and added a password key added from a PHP variable Possibly not the best example but you get the idea. CHeers -Neil At 02:06 22/06/2004 +0000, you wrote:
Date: Tue, 22 Jun 2004 12:06:41 +1000 Message-ID: <39B7E7009F2DD840AA747934AB551E69C62F3B@exnsw1-arm.nsw.csiro.au> From: <Justin.Baiocchi@csiro.au> To: <php-db@lists.php.net> Subject: Retrieve data, add new fields and enter it in new table Hi, I am trying to do the following: - retrieve data from a table based on the $id field (easy enough) - add a few more fields to the data set, then - enter the data (and new fields) into a new table (based on the selected $id field) I'm just not sure how to structure this, do I use a temporary table, add the new fields, then move the data set into the target table? Or is there a better way? Thanks Justin
======================================================== CaptionKit http://www.captionkit.com : Production tools for accessible subtitled internet media, transcripts and searchable video. Supports Real Player, Quicktime and Windows Media Player. VideoChat with friends online, get Freshly Toasted every day at http://www.fresh-toast.net : NetMeeting solutions for a connected world.

« previous php.db (#34858) next »