Re: stuck on values in 8.2 - Mailing list pgsql-general

From Gregory Stark
Subject Re: stuck on values in 8.2
Date
Msg-id 874pmi84gz.fsf@oxford.xeocode.com
Whole thread Raw
In response to stuck on values in 8.2  (Tom Allison <tom@tacocat.net>)
Responses Re: stuck on values in 8.2
List pgsql-general
"Tom Allison" <tom@tacocat.net> writes:

> OK, after reviewing many emails and what I was trying to do I upgraded from 8.2.
>
> Seems to work as it did in 8.1 which is a good start.
>
> I'm doing all of this so I can use the 'values'  that was described as being
> something like:
>
> select * from (values ('one','two','three')) "foo";

SELECT * FROM (VALUES ('one'),('two'),('three')) AS foo(value)

> I initially thought that I could do this with:
> select t.value, v.value from
> values('one','two','three') left outer join mytable using (value)

  postgres=# SELECT *
    FROM (VALUES ('one'),('two'),('three')) AS foo(value)
    LEFT OUTER JOIN mytable ON (foo.value = mytable.value);

   value | value
  -------+-------
   one   |
   two   | two
   three | three
  (3 rows)

"USING" would work too but then you only get one output column rather than two
which is not so helpful in this case.

  postgres=# SELECT *
    FROM (VALUES ('one'),('two'),('three')) AS foo(value)
    LEFT OUTER JOIN mytable USING (value) ;

   value
  -------
   one
   two
   three
  (3 rows)

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com


pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: postgres upgrade
Next
From: Tom Allison
Date:
Subject: Re: stuck on values in 8.2