Hi Jeffrey,
Thanks for your quick response!
Hoover, Jeffrey wrote:
>
> select (SELECT name from colnames WHERE id=1) as entry from entries;
>
I think, I should have been a bit clearer in what I need:
I've got two tables, colnames and entries:
test=# SELECT * from colnames;
id | name
----+------
1 | col1
(1 row)
test=# SELECT entry from entries;
entry
--------
first
second
third
(3 rows)
I would like to get the column name "entry" replaced by an alias "col1",
just like this:
test=# SELECT entry as col1 from entries;
col1
--------
first
second
third
(3 rows)
_But_, I don't want to give the alias explicitely, instead it should be
taken from a second table 'colnames', i.e. something like the line I
sent in my initial mail. Any idea?
Thanks again,
Felix
BTW, here's what I get from your command:
test=# select (SELECT name from colnames WHERE id=1) as entry from entries;
entry
-------
col1
col1
col1
(3 rows)