Search Postgresql Archives

Re: generic way to retrieve array as rowset

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

 



am  03.01.2006, um 12:37:51 +0100 mailte SunWuKung folgendes:
> When storing data in an array, like this
> 
> id	array
> 1, 	{1,2}
> 2, 	{10,20}
> 3, 	{100,200}

Forever 2 Elements in the array? Then:

test=# select * from t1;
 id |    foo
----+-----------
  1 | {1,2}
  2 | {10,20}
  3 | {100,200}
(3 rows)

test=# select id, array_upper(foo,1), foo[idx.i] from t1, generate_series (1, 2) idx(i);
 id | array_upper | foo
----+-------------+-----
  1 |           2 |   1
  1 |           2 |   2
  2 |           2 |  10
  2 |           2 |  20
  3 |           2 | 100
  3 |           2 | 200
(6 rows)


If not: http://www.varlena.com/GeneralBits/105.php
Read the chapter 'Querying and Flattening Array Columns'.


HTH, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    === 


[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