From: Markus Bertheau <twanger@bluetwanger.de>
To: Gurudutt <guru@indvalley.com>
Cc: postgres sql list <pgsql-sql@postgresql.org>
Subject: Re: Joins~
Date: 23 Nov 2001 08:55:22 +0100
Message-ID: <1006502123.4636.0.camel@entwicklung01.cenes.de> (raw)
In-Reply-To: <10524699358.20011122161018@indvalley.com>
References: <13216589307.20011121140728@indvalley.com>
<1006343880.29221.13.camel@entwicklung01.cenes.de>
<10524699358.20011122161018@indvalley.com>
> select tickettab.tokenid, ticketmultab.techcode,ticketmultab.techcode,
> tickettab.problemstmt,ticketmultab.problemstmt
> from (tickettab LEFT JOIN ticketmultab ON tickettab.tokenid=ticketmultab.tokenid)
> as ticketjoinedtab order by
> ticketjoinedtab.arrivaldate desc,
> ticketjoinedtab.arrivaltime desc
Oh, I see, joining is of course false, my fault. must be like this, i
think:
select <fields> from tablea union select <the same fields> from tableb
order by <field>
I tried it with two sample tables on 7.1.3 and it worked:
bert=> select version();
version
-------------------------------------------------------------
PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.96
(1 row)
bert=> \d ta
Table "ta"
Attribute | Type | Modifier
-----------+---------+-----------------------------------------------
id | integer | not null default nextval('"ta_id_seq"'::text)
data | text |
i | integer |
Index: ta_id_key
bert=> \d tb
Table "tb"
Attribute | Type | Modifier
-----------+---------+------------------------------------
id | integer | default nextval('ta_id_seq'::text)
data | text |
i | integer |
bert=> select * from ta;
id | data | i
----+------+---
1 | qwe | 1
2 | ert | 3
3 | tzu | 5
(3 rows)
bert=> select * from tb;
id | data | i
----+------+---
4 | wer | 2
5 | rtz | 4
6 | zui | 6
(3 rows)
bert=> select * from ta union select * from tb order by i;
id | data | i
----+------+---
1 | qwe | 1
4 | wer | 2
2 | ert | 3
5 | rtz | 4
3 | tzu | 5
6 | zui | 6
(6 rows)
Markus Bertheau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: twanger@bluetwanger.de, guru@indvalley.com
Subject: Re: Joins~
In-Reply-To: <1006502123.4636.0.camel@entwicklung01.cenes.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox