Re: Joins~

From: Markus Bertheau <twanger(at)bluetwanger(dot)de>
To: Gurudutt <guru(at)indvalley(dot)com>
Cc: postgres sql list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Joins~
Date: 2001-11-23 07:55:22
Message-ID: 1006502123.4636.0.camel@entwicklung01.cenes.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

> 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gurudutt 2001-11-23 08:11:43 Re: Joins~ - Thanks a lot~
Previous Message Andriy Pyrozhenko 2001-11-23 07:55:13 Re: Question