Select hardcoded values without table

postgresql

Solution

select a
from (
    values ('foo'), ('bar'), ('fooBar')
) s(a);

http://www.postgresql.org/docs/current/static/queries-values.html

Problem

I need to run a select without actually connecting to any table. I just have a predefined hardcoded set of values I need to loop over: ``` foo bar fooBar ``` And I want to loop through those values. I can do: ``` select 'foo', 'bar', 'fooBar'; ``` But this returns it as one row: ``` ?column? | ?column? | ?column? ----------+----------+---------- foo | bar | fooBar (1 row) ``` I am using Postgresql.

Original source