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

Fully qualified column names

From: "Dave Cramer" <Dave(at)micro-automation(dot)net>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Fully qualified column names
Date: 2001-08-20 19:02:13
Message-ID: 00c101c129aa$9f54d2c0$c201a8c0@inspiron (view raw or flat)
Thread:
Lists: pgsql-hackers
This is from the jdbc list. Is there any way to get fully qualified
column names?

Dave

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Ben Carterette
Sent: August 16, 2001 11:02 AM
To: Rene Pijlman
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] select on multiple tables


This won't work because I don't know in advance of the SELECT which 
tables I'm going to be selecting from.  The SELECT is done in a servlet 
that determines the tables based on request parameters.  I tried "SELECT

table1.*, table2.* FROM table1, table2", but it still can't tell the 
difference between columns with the same name.

Thanks for your help

ben


On Wednesday, August 15, 2001, at 06:29  PM, Rene Pijlman wrote:

> On Wed, 15 Aug 2001 16:43:31 -0500, Ben Carterette wrote:
>> I have a query like "SELECT * FROM table1, table2" and I want to read
>> values
>> out of a ResultSet.  What if the two tables have column names in 
>> common and
>> I can't predict the column numbers?  Is there any way to get
table1.id 
>> and
>> table2.id?  rs.getString tells me "The column name table1.id not 
>> found."
>
> Does this also happen when you explicitly name the columns?
>
>    SELECT table1.id, ..., table2.id, ...
>    FROM table1, table2
>
> Or if that doesn't help, try if a column label with the AS clause 
> works:
>
> SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
>     * | expression [ AS output_name ] [, ...] 
> http://www.postgresql.org/idocs/index.php?sql-select.html
>
>   SELECT table.id AS id1, ..., table2.id AS id2
>   FROM table1, table2
>
> And then rs.getString("id1");
>
> I think both solutions should work. Please let us know if they don't.
>
> Regards,
> René Pijlman
>

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster



Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2001-08-20 19:33:49
Subject: Re: CREATEDB Where ??
Previous:From: Peter EisentrautDate: 2001-08-20 18:12:10
Subject: Status of ipcclean

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