Search Postgresql Archives

Re: Copying data from one table to another - how to specify fields?

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

 



On Wed, Mar 09, 2011 at 02:47:46PM +0100, Alexander Farber wrote:
> I would like to copy these fields from one table:
> 
>   select user_id, username, user_email, user_regdate, user_lastvisit
> from phpbb_users where user_id > 50;
> 
> into the other (already existing) table:
> 
>   select uid, name, mail, created, access from drupal_users;
> 

INSERT INTO drupal users (uid, name, mail, created, access) 
       SELECT user_id, username, user_email, user_regdate, user_lastvist
         FROM phpbb_users where user_id > 50;

This is sort of like an example on
http://www.postgresql.org/docs/9.0/interactive/sql-insert.html, but
that example uses SELCT *.  Perhaps an additional example would have
helped?  (This is basic SQL, though, and I'm not sure the keyword
manual is the best place for such an example.)

A

-- 
Andrew Sullivan
ajs@xxxxxxxxxxxxxxx

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux