RE: Retrieve data, add new fields and enter it in new table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Gary and those who replied,

What I have ended up doing is using 3 tables: the original, a temporary
one and the target table. It's clunky and probably not the way to do it,
but this is my first php application and is just a learning exercise. 


-----Original Message-----
From: Gary Every [mailto:Gary.Every@xxxxxxxxxxxxxxxxxxxxxxx] 
Sent: Wednesday, 23 June 2004 4:36 AM
To: Baiocchi, Justin (LI, Armidale); php-db@xxxxxxxxxxxxx
Subject: RE:  Retrieve data, add new fields and enter it in new
table


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@xxxxxxxx [mailto:Justin.Baiocchi@xxxxxxxx] 
Sent: Monday, June 21, 2004 9:07 PM
To: php-db@xxxxxxxxxxxxx
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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux