Thread: jdbc question

jdbc question

From
Phillip Rhodes
Date:
If I submit a query joining two tables with identical column names, how can 
I differentiate the different columns and get the correct values?

table test1
(col1 INTEGER,
col2 INTEGER)

table test2
(col1 INTEGER,
col2 INTEGER)


select * from test1, test2
where test1.col1 = test2.col1

The call
rs.getInt("col1") returns successfully with a value, but there are 2 col1 
columns in the resultset.

Thanks,
Phillip



Re: [INTERFACES] jdbc question

From
Lars
Date:
Phillip,
I believe that you can just refer to the as column number, or cast them to
another name, ie;
SELECT (test1.column1 AS columnA, test2.column1)
FROM test1, test2;

-Lars

On Wed, 9 Feb 2000, Phillip Rhodes wrote:

> If I submit a query joining two tables with identical column names, how can 
> I differentiate the different columns and get the correct values?
> 
> table test1
> (col1 INTEGER,
> col2 INTEGER)
> 
> table test2
> (col1 INTEGER,
> col2 INTEGER)
> 
> 
> select * from test1, test2
> where test1.col1 = test2.col1
> 
> The call
> rs.getInt("col1") returns successfully with a value, but there are 2 col1 
> columns in the resultset.
> 
> Thanks,
> Phillip
> 
> 
> ************
> 
> 



Re: [INTERFACES] jdbc question

From
"Ken J. Wright"
Date:
At 15:50 02/09/2000 -0000, Phillip Rhodes wrote:
>If I submit a query joining two tables with identical column names, how can 
>I differentiate the different columns and get the correct values?
>
>table test1
>(col1 INTEGER,
>col2 INTEGER)
>
>table test2
>(col1 INTEGER,
>col2 INTEGER)
>
>
>select * from test1, test2
>where test1.col1 = test2.col1

select a.*, b.col1 as col3, b.col2 as col4 from test1 a, test2 b
where a.col1 = b.col1

>The call
>rs.getInt("col1") returns successfully with a value, but there are 2 col1 
>columns in the resultset.
>
>Thanks,
>Phillip
>
>
>************
>


Re: [INTERFACES] jdbc question

From
"Joe Shevland"
Date:
You could try:

---
SELECT test1.col1 AS t1c1, test2.col1 AS t2c1 FROM test1, test2 WHERE test1.col1 = test2.col1
---

The 'AS' being the important bit there as it will alias the parameters. I am
not sure whether rs.getInt("test1.col1") would work and I cannot test this
quickly where I am... anyone else?


Cheers,
Joe

----- Original Message ----- 
From: "Phillip Rhodes" <rhodespc@bellatlantic.net>
To: <pgsql-interfaces@postgreSQL.org>
Sent: Wednesday, February 09, 2000 7:50 AM
Subject: [INTERFACES] jdbc question


> If I submit a query joining two tables with identical column names, how can 
> I differentiate the different columns and get the correct values?
> 
> table test1
> (col1 INTEGER,
> col2 INTEGER)
> 
> table test2
> (col1 INTEGER,
> col2 INTEGER)
> 
> 
> select * from test1, test2
> where test1.col1 = test2.col1
> 
> The call
> rs.getInt("col1") returns successfully with a value, but there are 2 col1 
> columns in the resultset.
> 
> Thanks,
> Phillip
> 
> 
> ************
> 
> 



pgAdmin on NT (NT4SP6)

From
Tomaz Borstnar
Date:
Hello!
Due to too new version of COMCTL.DLL setup of pgadmin can't register 
mscal.ocx. This is known problem on NT, but I often get error 374: Failed 
to activate control "VB.UserControl". Is this another version of mscal.ocx 
problem?

It seems that pgadmin on win98 runs nicer which is weird, but first 
impression looks like it.

Thanks in advance.

Tomaz


----
Tomaz Borstnar <tomaz.borstnar@over.net>
"Love is the answer to the final question you ask" - Unknown