Skip site navigation (1) Skip section navigation (2)

Re[2]: How to join tables with different columns and different number of rows?

From: Igor <dbmanager(at)osb368(dot)nnov(dot)ru>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re[2]: How to join tables with different columns and different number of rows?
Date: 2001-06-27 10:25:23
Message-ID: 1195882311.20010627142523@osb368.nnov.ru (view raw or flat)
Thread:
Lists: pgsql-general
Thank you for replay, it is working, but
i would like to get result table with 5 rows.
In your example we willl get 8 rows

RH> From: "Igor" <dbmanager(at)osb368(dot)nnov(dot)ru>

>> Hello!
>> 
>> What SQL query will help me to concatenate two different tables
>> with different number of rows? For example , i have first table
>> with column1 and column2 , having 3 rows , and second table
>> with column3, column4 , having 5 rows. How to make
>> third table with column1,column2,column3,column4 and 5 rows in it
>> (and last two rows in column1 and column2 are empty)

RH> Something along the lines of:

RH> SELECT col1,col2,'' as dummy3, '' as dummy4
RH> FROM table1
RH> UNION
RH> SELECT '' as dummy1, '' as dummy2, col3, col4
RH> FROM table2



In response to

Responses

pgsql-general by date

Next:From: Martijn van OosterhoutDate: 2001-06-27 10:45:20
Subject: Re: How to join tables with different columns and different number of rows?
Previous:From: Alex PilosovDate: 2001-06-27 10:20:55
Subject: Re: Blobs in PostgreSQL

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group