Re: Tablenames in Resultsets?

From: Ivan Cornell <ivan(dot)cornell(at)framestore(dot)co(dot)uk>
To: gb(at)a3design(dot)de
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Tablenames in Resultsets?
Date: 2000-09-27 08:28:18
Message-ID: 39D1AFA2.DBEC07C3@framestore.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

gb(at)a3design(dot)de wrote:

> select * from test1, test2 where test1.id=test2.id
>
>
> but I need:
>
> test1.id | test1.value | test2.id | test2.value
> -----------------------------------------------
> ...
>
> because I dont want to access the fields by index but by name!!!
>

My solution would be
select t1.id as test1_id, t1.value as test1_value, t2_id as test2_id,
t2.value as test2_value from test1 t1, test2 t2 where t1.id = t2.id
You don't have to rename the tables (in this case to t1.t2), but it can
really reduce your query string length!

Ivan.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Alexi Margo 2000-09-27 08:37:07 RE: Re: Encrypting fields with a one-way hash
Previous Message Manfred Pock 2000-09-27 08:23:24 Postgresql 7.0.2 under WinNT