Inserting data of two other tables

From: papapep <papapep(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Inserting data of two other tables
Date: 2003-05-23 18:45:32
Message-ID: 3ECE6C4C.3000204@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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-----

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Manfred Koizar 2003-05-23 19:14:59 Re: Inserting data of two other tables
Previous Message Josh Berkus 2003-05-23 16:12:45 Re: Problem on Cygwin