Search Postgresql Archives

Multiple unnests in query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good night,

Is this first query expected behavior? If so, what is the rationale? I
would have expected nine rows returned (as in my second example).

Regards,
Aron Widforss

SELECT
  unnest(ARRAY[1, 1, 2]) AS unnested1,
  unnest(ARRAY[3, 3, 4]) AS unnested2
;
 unnested1 | unnested2 
-----------+-----------
         1 |         3
         1 |         3
         2 |         4
(3 rows)

SELECT
  unnest(ARRAY[1, 1, 2]) AS unnested1,
  sec
FROM (SELECT 3 AS sec UNION ALL
      SELECT 3 AS sec UNION ALL
      SELECT 4 AS sec) test
;
 unnested1 | sec 
-----------+-----
         1 |   3
         1 |   3
         2 |   3
         1 |   3
         1 |   3
         2 |   3
         1 |   4
         1 |   4
         2 |   4
(9 rows)


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux