macromedia.coldfusion.database_access
[Top] [All Lists]

Re: Creat new table from multiple tables in same DB?

Subject: Re: Creat new table from multiple tables in same DB?
From: "paross1" <webforumsuser@xxxxxxxxxxxxxx>
Date: Tue, 29 Jul 2008 14:39:26 +0000 (UTC)
Newsgroups: macromedia.coldfusion.database_access

Are you just consolidating your data or something? Are these tables related to 
each other? Are you doing this to eventually remove the other tables, or are 
you planning on having this "other" table in addition to the others? If you 
aren't going to remove the other tables then you probably don't want to create 
a new table but to use a SQL query to create a virtual table instead by joining 
all of the other tables on the appropriate fields.

 If you really want to create this other table, then something like this might 
be what you want to do:

 CREATE TABLE newtable
 AS
 SELECT old_ID as new_ID, ...
 FROM oldtable1
 UNION 
 SELECT old_ID as new_ID, ...
 FROM oldtable2
 UNION
 SELECT old_ID as new_ID, ...
 FROM oldtable3
 .....

 Phil


<Prev in Thread] Current Thread [Next in Thread>