Re: Joins~ - Thanks a lot~

From: Gurudutt <guru(at)indvalley(dot)com>
To: Markus Bertheau <twanger(at)bluetwanger(dot)de>
Cc: postgres sql list <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Joins~ - Thanks a lot~
Date: 2001-11-23 08:11:43
Message-ID: 1575268728.20011123134143@indvalley.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello Markus,

It worked like anything, Thanks a lot, actually it saved so much of my
code in php, infact a function had been writted to do the same.

Thanks again

--
Best regards,
Gurudutt mailto:guru(at)indvalley(dot)com

Life is not fair - get used to it.
Bill Gates

Friday, November 23, 2001, 1:25:22 PM, you wrote:

>> 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
MB> Oh, I see, joining is of course false, my fault. must be like this, i
MB> think:
MB> select <fields> from tablea union select <the same fields> from tableb
MB> order by <field>

MB> I tried it with two sample tables on 7.1.3 and it worked:
bert=>> select version();
MB> version
MB> -------------------------------------------------------------
MB> PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by GCC 2.96
MB> (1 row)

bert=>> \d ta
MB> Table "ta"
MB> Attribute | Type | Modifier
MB> -----------+---------+-----------------------------------------------
MB> id | integer | not null default nextval('"ta_id_seq"'::text)
MB> data | text |
MB> i | integer |
MB> Index: ta_id_key

bert=>> \d tb
MB> Table "tb"
MB> Attribute | Type | Modifier
MB> -----------+---------+------------------------------------
MB> id | integer | default nextval('ta_id_seq'::text)
MB> data | text |
MB> i | integer |

bert=>> select * from ta;
MB> id | data | i
MB> ----+------+---
MB> 1 | qwe | 1
MB> 2 | ert | 3
MB> 3 | tzu | 5
MB> (3 rows)

bert=>> select * from tb;
MB> id | data | i
MB> ----+------+---
MB> 4 | wer | 2
MB> 5 | rtz | 4
MB> 6 | zui | 6
MB> (3 rows)

bert=>> select * from ta union select * from tb order by i;
MB> id | data | i
MB> ----+------+---
MB> 1 | qwe | 1
MB> 4 | wer | 2
MB> 2 | ert | 3
MB> 5 | rtz | 4
MB> 3 | tzu | 5
MB> 6 | zui | 6
MB> (6 rows)

MB> Markus Bertheau

In response to

  • Re: Joins~ at 2001-11-23 07:55:22 from Markus Bertheau

Browse pgsql-sql by date

  From Date Subject
Next Message Joe McGuckin 2001-11-23 09:44:56 How to find missing values in a sequence ?
Previous Message Markus Bertheau 2001-11-23 07:55:22 Re: Joins~