pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedquery an array...
2+ messages / 2 participants
[nested] [flat]
* query an array...
@ 1999-05-19 06:56 Heiko Wilms <wilms@stud.fh-hannover.de>
1999-05-19 13:28 ` Re: [SQL] query an array... Jason Earl <jearl@box100.com>
0 siblings, 1 reply; 2+ messages in thread
From: Heiko Wilms @ 1999-05-19 06:56 UTC (permalink / raw)
To: pgsql-sql@hub.org
> Hi,
>
> I stucked upon the following situation:
> create table test (
> n int[] );
>
> insert into test values (
>
> '{1,2,3,4}'
>
> );
>
> now I need a query that returns all four numbers in different variables,i.e.
>
> an array like n[1],...,n[4]
>
> I tried queries like
>
> select test.n from test which returns {1,2,3,4}
>
> or
>
> select test.n[i] from test, where i is 1,2,3 or 4 which each returns 1,2,...
>
> What I'm looking for is a query that returns four rows with one number in each
>
> result index. Can anyone help?
>
--
H. Wilms
Homepage schering.si2.uni-hannover.de/hugo
email wilms@stud.fh-hannover.de
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [SQL] query an array...
1999-05-19 06:56 query an array... Heiko Wilms <wilms@stud.fh-hannover.de>
@ 1999-05-19 13:28 ` Jason Earl <jearl@box100.com>
0 siblings, 0 replies; 2+ messages in thread
From: Jason Earl @ 1999-05-19 13:28 UTC (permalink / raw)
To: wilms@stud.fh-hannover.de; +Cc: pgsql-sql@hub.org
Try:
SELECT test.n[1], test.n[2], test.n[3], test.n[4] from test;
It should get you what you need.
Or you could make it a little more clear with something like:
SELECT
test.n[1] as one, test.n[2] as two, test.n[3] as three,
test.n[4] as four
FROM test;
As that would give you more descriptive column names (which is a
useful thing in PHP).
> Hi,
>
> I stucked upon the following situation:
> create table test (
> n int[] );
>
> insert into test values (
>
> '{1,2,3,4}'
>
> );
>
> now I need a query that returns all four numbers in different
> variables,i.e.
>
> an array like n[1],...,n[4]
>
> I tried queries like
>
> select test.n from test which returns {1,2,3,4}
>
> or
>
> select test.n[i] from test, where i is 1,2,3 or 4 which each
> returns 1,2,...
>
> What I'm looking for is a query that returns four rows with one
> number in each
>
> result index. Can anyone help?
>
--
H. Wilms
Homepage schering.si2.uni-hannover.de/hugo
email wilms@stud.fh-hannover.de
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~1999-05-19 13:28 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-05-19 06:56 query an array... Heiko Wilms <wilms@stud.fh-hannover.de>
1999-05-19 13:28 ` Jason Earl <jearl@box100.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox