Re: [JDBC] create view problem

From: Kris Jurka <books(at)ejurka(dot)com>
To: Simon Moses <ks_moses(at)yahoo(dot)com>
Cc: pgsql general <pgsql-general(at)postgresql(dot)org>, pgsql jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [JDBC] create view problem
Date: 2004-10-18 05:42:01
Message-ID: Pine.BSO.4.56.0410180039480.15898@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

On Sun, 17 Oct 2004, Simon Moses wrote:

> dear sir,
> i am trying to create view with following query

This has nothing to do with JDBC or Java, so it should not be sent to the
JDBC list.

> create view salesQ as
> select * from sales, customer where sales.customerkey
> = customer.customerkey;
>
> it is giving
>
> ERROR: column "customerkey" duplicated
>
> create view salesQ as
> select sales.*, customer.* from sales, customer where
> sales.customerkey = customer.customerkey;
>
> also giving same error.
> i cannot change field names or specify field names in
> view definition because many fields are there in both
> tables. how to create this view?
>

You need to use aliases in your SELECT...

SELECT sales.customerkey AS salescustomerkey, customer.customerkey AS
customercustomerkey, ... FROM sales, customer WHERE ...

Kris Jurka

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Neil Conway 2004-10-18 06:43:26 Re: 8.0.0beta3 vacuum analyze
Previous Message Simon Moses 2004-10-18 05:36:31 create view problem

Browse pgsql-jdbc by date

  From Date Subject
Next Message Devrim GUNDUZ 2004-10-18 07:55:21 Initial translation : Turkish
Previous Message Simon Moses 2004-10-18 05:36:31 create view problem