Обсуждение: display array field as row
Dear all,
Does anyone know how to display an array data into row?
for exampla, I have data like this
And I want to to display those data above like below
kelas_pkey p 1
kelas_pkey p 2
kelas_tahun f 2
Do you know any sql syntax that would do?
I cannot find it in documentation
or is it not possible?
Regards
Hendra
Does anyone know how to display an array data into row?
for exampla, I have data like this
conname | contype | conkey | |||
---|---|---|---|---|---|
kelas_pkey | p | {1,2} | |||
kelas_tahun | f | {2} |
And I want to to display those data above like below
kelas_pkey p 1
kelas_pkey p 2
kelas_tahun f 2
Do you know any sql syntax that would do?
I cannot find it in documentation
or is it not possible?
Regards
Hendra
Hello create or replace function unnest(anyarray) returns setof anyelement as $$ select $1[i] from generate_series(array_lower($1,1),array_upper($1,1)) g(i); $$ language sql immutable; select conname, contype, unnest(conkey) from ... regards Pavel Stehule 2009/2/3 hendra kusuma <penguinroad@gmail.com>: > Dear all, > > Does anyone know how to display an array data into row? > for exampla, I have data like this > > conname contype conkey > > > kelas_pkey p {1,2} > > > kelas_tahun f {2} > > > > And I want to to display those data above like below > > kelas_pkey p 1 > kelas_pkey p 2 > kelas_tahun f 2 > > Do you know any sql syntax that would do? > I cannot find it in documentation > or is it not possible? > > Regards > Hendra >