agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: ktm@rice.edu <ktm@rice.edu>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Jason Aleski <jason.aleski@gmail.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: ERROR: column "gid" specified more than once
Date: Tue, 12 May 2015 12:02:01 -0500
Message-ID: <20150512170201.GI31129@aart.rice.edu> (raw)
In-Reply-To: <CAKFQuwa_rV-0on6ieYp-v4MTayDs_wtFbo-H6_58071H8hGkTg@mail.gmail.com>
References: <1431419471426-5848845.post@n5.nabble.com>
<55521B89.1090900@gmail.com>
<CAKFQuwaqLKUkr7Hcp219kVcMb7YmsBjK9qu6tsU7MHC-QyUScg@mail.gmail.com>
<20150512155309.GH31129@aart.rice.edu>
<CAKFQuwYuXsPX0d4j+wKdBORjL2puSJZwR=X3ayH4+nN9iRkgvA@mail.gmail.com>
<CAKFQuwa_rV-0on6ieYp-v4MTayDs_wtFbo-H6_58071H8hGkTg@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
On Tue, May 12, 2015 at 09:19:23AM -0700, David G. Johnston wrote:
> On Tue, May 12, 2015 at 9:09 AM, David G. Johnston <
> david.g.johnston@gmail.com> wrote:
>
> > On Tue, May 12, 2015 at 8:53 AM, ktm@rice.edu <ktm@rice.edu> wrote:
> >
> >> On Tue, May 12, 2015 at 08:49:53AM -0700, David G. Johnston wrote:
> >> > On Tuesday, May 12, 2015, Jason Aleski <jason.aleski@gmail.com> wrote:
> >> >
> >> > > You probably need to specify your wildcard on both tables.
> >> > >
> >> > > CREATE TABLE "BorujerdDistCent" as
> >> > > SELECT
> >> > > "Borujerd".*, "Lorestan".*,
> >> > > t_distance(st_centroid("Lorestan".geometry),"Borujerd".geometry)/1000
> >> > > as DistFromCntroid
> >> > > FROM "Borujerd", "Lorestan"
> >> > >
> >> > >
> >> > My bad on the assumed -bugs list from before...
> >> >
> >> > Anyway, how is this suugestion different from simply saying "*" without
> >> a
> >> > relation specification - which the OP did and it didn't work.
> >> >
> >> > David J.
> >>
> >> Because the column names are differentiated by their prefixes then:
> >>
> >> Borujerd.gid, Lorestan.gid
> >>
> >> No conflict.
> >>
> >>
> > I suggest you test that theory out.
> >
> >
> The reason why this advice is wrong is because the error is coming from
> the CREATE TABLE AS portion and not the select query.
>
> Within the following:
>
> CREATE TABLE testtable AS
> SELECT t1.*, t2.*
> FROM ( VALUES (1::int) ) t1 (s)
> CROSS JOIN ( VALUES (2::int) ) t2 (s)
>
> executing just the SELECT portion will indeed output a two-column result
> with both columns named "s".
>
> However, it is not possible to create a table with two columns having the
> same name and so using the exact same query will fail with the duplicate
> name error.
>
> The only way to solve the problem is to alias the output columns or choose
> not to output one of the columns.
>
> SELECT t1.s AS s_t1, t2.s AS s_t2 FROM [...]
> or
> SELECT t1.* FROM [...]
>
> As shown above column names in the result do not carry over their source
> identifier - just the name itself.
>
> David J.
Yes. You are correct. Sorry for the noise.
Ken
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (8+ messages)
Message-ID: <20150512170201.GI31129@aart.rice.edu>
Permalink: ../20150512170201.GI31129@aart.rice.edu/
Also on: postgresql.org/message-id/20150512170201.GI31129@aart.rice.edu
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ktm@rice.edu, david.g.johnston@gmail.com, jason.aleski@gmail.com
Subject: Re: ERROR: column "gid" specified more than once
In-Reply-To: <20150512170201.GI31129@aart.rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox