Click to See Complete Forum and Search --> : create sql table from query result.


ss1289
05-05-2008, 05:35 PM
In PostgreSQL, I'm trying to create a table in one database using the results of a select query in another totally different database.
Now the only way I know of to do this is to get the results from one table and run a bunch of inserts into the other table.
But I was wondering if there was a way to do it where I could create a table on the fly, like the following somehow

CREATE TABLE newTable AS (//results from the other table in the other database);

I'm not sure if this is possible since you're creating a table in one database from the results of a table in another database. You can't mix the two databases that easily, can you?

Any advice on how to do this would be greatly appreciated.

ss1289
05-06-2008, 09:19 AM
Actually the reason I posted this in the PHP forum is that I was hoping that I could somehow use the result of php query() function to use as the argument for the "CREATE TABLE AS ()".

Any ideas?

chazzy
05-06-2008, 12:45 PM
can the two databases talk to one another, or are they foreign?

ss1289
05-06-2008, 05:24 PM
can the two databases talk to one another, or are they foreign?
What do you mean by foreign? The databases require different login info but are on the same server.

But anyways, how could you make them interact with each other?