Inserting data of two other tables - Mailing list pgsql-novice

From papapep
Subject Inserting data of two other tables
Date
Msg-id 3ECE6C4C.3000204@gmx.net
Whole thread Raw
Responses Re: Inserting data of two other tables
Re: Inserting data of two other tables
List pgsql-novice
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I need to insert data into a table getting it from two other tables.
I've tried to do it wiht an INSERT INTO statement, but I don't know
exactly why it seems it doesn't work. At least the operation gets
"hanged" for plenty of time until I cancel it :-(

The sentence that I try to make what I want is:

INSERT INTO totaltrajectes (turno, condu, linea, fecha, nserie,
nseriechip,tipotrbus,paraor,parade,hora1hora,hora1min,pasaindi,numvez,clase,
tarifa,tarneto,tarbruto,formapago,texto,journey,salreca) SELECT
turno,condu,linea,fecha,nserie,nseriechip,tipotrbus,paraor,parade,
hora1hora,hora1min,pasaindi,numvez,clase,tarifa,tarneto,tarbruto,
formapago,texto,journey,salreca from captrajectes,detalltrajectes

Also I have to mention that this sentence works with about 650.000 rows
~                                in the table "detalltrajectes" and
35.000 in the "captrajectes" one. The fields turno, condu, linea and
fecha are from captrajectes, and the rest from detalltrajectes.
Captrajectes is a header file and every row from this table refers to
many rows of detalltrajectes, and they get linked with two fields that
are identical. In captrajectes pkey is the primary key and in
detalltrajectes journey is the field that refers to pkey letting us know
to wich header every row belongs.

Does anybody know a more effective way to fill the new table? At least
to make me able to do it...

Thanks in advance for your help.

Josep Sànchez
~ [papapep]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+zmxK2vx52x0kyz4RAjl/AKDBFZTC08EQmytShbRyExe9+hfqWgCeLPtu
oAn2OmnicvXXEZH6eLfv/84=
=MuaD
-----END PGP SIGNATURE-----




pgsql-novice by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Problem on Cygwin
Next
From: Manfred Koizar
Date:
Subject: Re: Inserting data of two other tables