From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: CTE containing ambiguous columns |
Date: | 2009-11-13 06:25:26 |
Message-ID: | 25460.1258093526@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> Suppose you do this:
> create table animals (id serial primary key, name varchar not null);
> Then you can do this:
> with beings as (select * from animals) select * from beings where id = 1;
> But not this:
> with beings as (select * from animals a1, animals a2) select * from
> beings where id = 1;
No different from
regression=# select * from (animals a1 cross join animals a2) x where id = 1;
ERROR: column reference "id" is ambiguous
LINE 1: ...ct * from (animals a1 cross join animals a2) x where id = 1;
^
There's no way to access the a1/a2 aliases here, either; and that rule
goes back to SQL92 or maybe further.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2009-11-13 06:35:12 | Re: Patch committers |
Previous Message | Greg Smith | 2009-11-13 06:19:42 | Re: [PATCH] SE-PgSQL/lite (r2429) |