RE: [PHP-DB] Retrieve data, add new fields and enter it in new table
| From: | Gary Every | Date: | Tue, 22 Jun 2004 18:36:24 +0000 |
| Subject: | RE: [PHP-DB] Retrieve data, add new fields and enter it in new table | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-34864@lists.php.net to get a copy of this message | ||
Let's say you want to build a table with a couple extra fields, say the
name associated with the id, and today's date
Try:
CREATE TABLE new_table SELECT t1.id, t2.id_name, NOW() FROM table1 t1,
table2 t2 WHERE t1.id=t2.id
This will build a table with all the id's from table1 that have an
associated name in table2 as well as the date (NOW())
It will have no indexes, though, so you could use the ALTER TABLE
command after it was created.
See :
http://dev.mysql.com/doc/mysql/en/CREATE_TABLE.html
for more info on the create table syntax
Gary Every
Sr. UNIX Administrator
Ingram Entertainment Inc.
2 Ingram Blvd, La Vergne, TN 37089
"Pay It Forward!"
-----Original Message-----
From: Justin.Baiocchi@csiro.au [mailto:Justin.Baiocchi@csiro.au]
Sent: Monday, June 21, 2004 9:07 PM
To: php-db@lists.php.net
Subject: [PHP-DB] 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
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php