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

2011-03-09 Thread Alexander Farber
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) tabl

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

2011-03-09 Thread Andrew Sullivan
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, nam

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

2011-03-09 Thread Michael Glaesemann
On Mar 9, 2011, at 08:47 , Alexander Farber wrote: > 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 p

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

2011-03-09 Thread Alexander Farber
Oh it is called "INSERT INTO", thank you! I still have a problem though: # select uid, name, mail, created, access from drupal_users; uid | name |mail| created | access -+--+++ 0 | |

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

2011-03-09 Thread Raymond O'Donnell
On 09/03/2011 14:21, Alexander Farber wrote: Oh it is called "INSERT INTO", thank you! I still have a problem though: # select uid, name, mail, created, access from drupal_users; uid | name |mail| created | access -+--++

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

2011-03-09 Thread Alexander Farber
Hello Raymond and others, thank you for looking at my problem! It is a core Drupal 7 table, with a prefix "drupal_" (you can set it while installing Drupal 7 in adv. options). I have only 2 records in that target table: # select uid, name, mail, created, access from drupal_users; uid | name |

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

2011-03-09 Thread Alexander Farber
I've also tried renaming 'Alex' to a temp. value: # update drupal_users set name='Alex_1972' where name='Alex'; UPDATE 1 # INSERT INTO drupal_users (uid, name, mail, created, access) SELECT user_id, username, user_email, user_regdate, user_lastvisit FROM phpbb_users WHERE user_id > 50 and

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

2011-03-09 Thread Alexander Farber
Oh ok, found it: # select one.username, one.user_id, two.user_id from phpbb_users one, phpbb_users two where two.username=one.username and two.user_id <> one.user_id; username | user_id | user_id --+-+- Вячеслав |7564 | 421 Вячеслав | 421 |7564 (2 rows)

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

2011-03-09 Thread David Johnston
ay, March 09, 2011 9:21 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Copying data from one table to another - how to specify fields? Oh it is called "INSERT INTO", thank you! I still have a problem though: # select uid, name, mail, created, access from drupal_users;

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

2011-03-09 Thread David Johnston
-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Alexander Farber Sent: Wednesday, March 09, 2011 9:48 AM To: pgsql-general@postgresql.org Subject: Re: [GENERAL] Copying data from one table to another - how to specify fields? Hello Raymond and others, thank you for looking at

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

2011-03-15 Thread Alexander Farber
Thank you all for the replies! On Wed, Mar 9, 2011 at 7:01 PM, David Johnston wrote: > SELECT username, count(username) FROM phpbb_users > GROUP BY username > HAVING count(username) > 1; > > If anything shows up then (phpbb_users .username) is not a unique field but > you are trying to insert it