Re: CTE containing ambiguous columns - Mailing list pgsql-hackers

From Tom Lane
Subject Re: CTE containing ambiguous columns
Date
Msg-id 25460.1258093526@sss.pgh.pa.us
Whole thread Raw
In response to CTE containing ambiguous columns  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Robert Haas <robertmhaas@gmail.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


pgsql-hackers by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: EOL for 7.4?
Next
From: Tom Lane
Date:
Subject: Re: Patch committers