Re: [SQL] Always getting back a row, even with no results
От | Jonathan Moules |
---|---|
Тема | Re: [SQL] Always getting back a row, even with no results |
Дата | |
Msg-id | 15dd1ef824a.11e71b280106536.5163340769196231808@lightpear.com обсуждение исходный текст |
Ответ на | Re: [SQL] Always getting back a row, even with no results ("David G. Johnston" <david.g.johnston@gmail.com>) |
Ответы |
Re: [SQL] Always getting back a row, even with no results
|
Список | pgsql-sql |
Hi David,
I'm afraid I don't really understand this response (I've not done much with arrays), but it doesn't seem to work for my purpose.
No NULL is returned if there is no result (i.e. cat = 50); instead, there's simply no rows.
What aspect of Arrays is this trying to take advantage of?
Cheers,
Jonathan
---- On Fri, 11 Aug 2017 16:18:04 +0100 David G. Johnston<david.g.johnston@gmail.com> wrote ----
I'm afraid I don't really understand this response (I've not done much with arrays), but it doesn't seem to work for my purpose.
No NULL is returned if there is no result (i.e. cat = 50); instead, there's simply no rows.
What aspect of Arrays is this trying to take advantage of?
Cheers,
Jonathan
---- On Fri, 11 Aug 2017 16:18:04 +0100 David G. Johnston<david.g.johnston@gmail.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.untestedSELECT 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 по дате отправления: