Re: [SQL] Always getting back a row, even with no results

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [SQL] Always getting back a row, even with no results
Дата
Msg-id CAKFQuwYxL33=Az3EiH-=1-R1cHLSs98zUDvtcLgZDURoc3wYHQ@mail.gmail.com
обсуждение исходный текст
Ответ на [SQL] Always getting back a row, even with no results  (Jonathan Moules <jonathan-lists@lightpear.com>)
Ответы Re: [SQL] Always getting back a row, even with no results
Список pgsql-sql
On Fri, Aug 11, 2017 at 6:57 AM, Jonathan Moules <jonathan-lists@lightpear.com> wrote:
This will of course return the two rows with that category. But I also want to be able to run the query with a non-existent cat and get a result of "null" for the id.

​untested​

​SELECT unnest( ARRAY( (​
 select id from my_table where cat = 50
​​ ) ) );

tested, self-contained, example:

SELECT unnest(ARRAY((SELECT col FROM ( VALUES (1), (2) ) vals (col) WHERE true)))

David J.

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

Предыдущее
От: Achilleas Mantzios
Дата:
Сообщение: Re: [SQL] Always getting back a row, even with no results
Следующее
От: Jonathan Moules
Дата:
Сообщение: Re: [SQL] Always getting back a row, even with no results