Re: Converting query to view - duplicate fields - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: Converting query to view - duplicate fields
Date
Msg-id 20040309181341.S12789@megazone.bigpanda.com
Whole thread Raw
In response to Converting query to view - duplicate fields  (Richard Grosse <lists@keep-trying.com>)
Responses Re: Converting query to view - duplicate fields - solved
List pgsql-sql
On Tue, 9 Mar 2004, Richard Grosse wrote:

> Trying to convert the query below to a view. The problem is
> despite it working as a query when trying to save it as a
> view  the database returns the error that the field tablealias.cmpname
> is duplicated. (Which it is and has to be)

You're going to need to use column aliases to alias (for example)
tbldeliver.cmpname, tblsender.cmpname, tblhaulier.cmpname to different
aliases in the view, perhaps
"tbldeliver.cmpname" "tblsender.cmpname" and "tblhaulier.cmpname"
(note the double quotes).

> CREATE OR REPLACE VIEW public.test AS
> SELECT mhdespatch.gdn, mhdespatch.date, mhdespatch.remarks,
> mhdespatch.sp_instruct1,
> mhdespatch.sp_instruct2, mhdespatch.sp_instruct3, tbldelivery.cmpname,
> tbldelivery.adds1, tbldelivery.adds2, tbldelivery.adds3, tbldelivery.town,
> tbldelivery.county, tbldelivery.pcode, tbldelivery.country, tbldelivery.tel1,
> mhdespatch.del_ref, tblsender.cmpname, mhdespatch.send_ref,
> tblhaulier.cmpname,
> mhdespatch.haul_reg, mhdespatch.cov, tblhaulier.tel1
> FROM mhdespatch
> INNER JOIN tblfmna AS tblhaulier ON mhdespatch.haul_code = tblhaulier.code
> INNER JOIN tblfmna AS tblsender ON mhdespatch.send_code = tblsender.code
> INNER JOIN tblfmna AS tbldelivery ON mhdespatch.del_code = tbldelivery.code;


pgsql-sql by date:

Previous
From: Richard Grosse
Date:
Subject: Converting query to view - duplicate fields
Next
From: azwa@nc.com.my
Date:
Subject: pg_hba.conf