Re: Strange interaction of union and expressions - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Strange interaction of union and expressions
Date
Msg-id 20050420201050.GA2218@dcc.uchile.cl
Whole thread Raw
In response to Strange interaction of union and expressions  (Aaron Bingham <bingham@cenix-bioscience.com>)
List pgsql-general
On Wed, Apr 20, 2005 at 07:24:08PM +0200, Aaron Bingham wrote:

Hi,

> create table a (foo varchar);
>x insert into a (foo) values ('baz');
> create table b (foo varchar);
> insert into b (foo) values ('woof');
> select '"' || foo || '"' as foo
>     from (select foo from a) as bar
>         union select foo from b;

It's a precedence issue; not a problem really.  Try this:

select '"' || foo || '"' as foo
     from (select foo from a
         union select foo from b) as bar;

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"¿Que diferencia tiene para los muertos, los huérfanos, y aquellos que han
perdido su hogar, si la loca destrucción ha sido realizada bajo el nombre
del totalitarismo o del santo nombre de la libertad y la democracia?" (Gandhi)

pgsql-general by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: Strange interaction of union and expressions
Next
From: Kevin Murphy
Date:
Subject: Re: Strange interaction of union and expressions