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

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Copying data from one table to another - how to specify fields?
Date: 2011-03-09 13:47:46
Message-ID: AANLkTimRiFMPeVwQK0iwMWrWLEKH1j2NUT9pdD9OfQYR@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

I'm using CentOS 5.5 with PostgreSQL 8.4.7 and
am migrating my site from phpBB 3 to Drupal 7.

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;

I've read http://www.postgresql.org/docs/8.4/static/sql-selectinto.html
and few more docs but don't understand, how could I specify the
fields correspondence (i.e. phpbb_users.user_id -> drupal_users.uid)

Also the target table exists already, has some records already
and has more fields than specified in my select statement above.

Thank you
Alex

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Vincent Veyron 2011-03-09 13:55:42 Re: Web Hosting
Previous Message Dmitriy Igrishin 2011-03-09 13:34:41 Re: Why length(to_char(1::integer, '9')) = 2 ?