Re: Strange interaction of union and expressions

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Aaron Bingham <bingham(at)cenix-bioscience(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, Gregory Gimenez <gimenez(at)cenix-bioscience(dot)com>
Subject: Re: Strange interaction of union and expressions
Date: 2005-04-20 20:10:50
Message-ID: 20050420201050.GA2218@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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[(at)]dcc(dot)uchile(dot)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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher J. Bottaro 2005-04-20 21:17:05 CURRENT_TIMESTAMP and actual time
Previous Message Oleg Bartunov 2005-04-20 20:08:04 Re: Strange interaction of union and expressions