SELECT with column specified by subquery

Поиск
Список
Период
Сортировка
От webcoyote
Тема SELECT with column specified by subquery
Дата
Msg-id 1399317326878-5802533.post@n5.nabble.com
обсуждение исходный текст
Ответы Re: SELECT with column specified by subquery
Список pgsql-general
I desire to create a SELECT statement where one of the column names comes
from another table.  Something like:

  SELECT id, (SELECT type FROM favorite_food_type WHERE user = 'ralph')
  FROM foods;

If Ralph's favorite food type is fruit, ultimately I'd like the query to
become:

  SELECT id, fruit FROM foods;

Instead I get:

  SELECT id, 'fruit' FROM foods;

Where 'fruit' is a string and not treated as a column name.  Is there any
way to do this?

Thank you!



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/SELECT-with-column-specified-by-subquery-tp5802533.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: DrakoRod
Дата:
Сообщение: Re: Server continuously enters to recovery mode.
Следующее
От: David G Johnston
Дата:
Сообщение: Re: SELECT with column specified by subquery