RE: very simple: How can I multiply tables?

From: Michael Ansley <Michael(dot)Ansley(at)intec-telecom-systems(dot)com>
To: "'mik(at)nix(dot)org(dot)ru'" <mik(at)nix(dot)org(dot)ru>, pgsql-general(at)postgresql(dot)org
Subject: RE: very simple: How can I multiply tables?
Date: 2001-02-14 15:10:40
Message-ID: 7F124BC48D56D411812500D0B747251480F40E@FILESERVER002
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

INSERT INTO table3 (id, surname, dt) SELECT table1.id, table1.surname,
table2.dt FROM table1, table2;
or
CREATE TABLE table3 AS SELECT table1.id, table1.surname, table2.dt FROM
table1, table2;

It's called a cross-join.

Cheers...

MikeA

-----Original Message-----
From: Mikhail V. Majorov [mailto:mik(at)ttn(dot)ru]
Sent: 14 February 2001 14:49
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] very simple: How can I multiply tables?

Hi, question

How can I multiply tables using SELECT?

Table 1

id surname
--------------
1 AAA
2 BBB
3 CCC
4 DDD

Table 2

dt
---
12
35

RESULT

id surname dt
---------------------------
1 AAA 12
2 BBB 12
3 CCC 12
4 DDD 12
1 AAA 35
2 BBB 35
3 CCC 35
4 DDD 35

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
Nick West - Global Infrastructure Manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2001-02-14 15:12:06 Re: Bad book review
Previous Message Fred Yankowski 2001-02-14 15:09:56 Re: Bad book review