Received: from earlj.nesusa.com (fw1.nesusa.com [204.31.203.254]) by hub.org (8.9.3/8.9.3) with ESMTP id JAA95917 for ; Wed, 19 May 1999 09:27:48 -0400 (EDT) (envelope-from jearl@box100.com) Received: (from earlj@localhost) by earlj.nesusa.com (8.8.7/8.8.7) id HAA29087; Wed, 19 May 1999 07:28:27 -0600 Date: Wed, 19 May 1999 07:28:27 -0600 Message-Id: <199905191328.HAA29087@earlj.nesusa.com> X-Authentication-Warning: earlj.nesusa.com: earlj set sender to jearl@box100.com using -f From: Jason Earl To: wilms@stud.fh-hannover.de CC: pgsql-sql@hub.org In-reply-to: <37426096.158674B9@stud.fh-hannover.de> (message from Heiko Wilms on Wed, 19 May 1999 08:56:22 +0200) Subject: Re: [SQL] query an array... References: <37426096.158674B9@stud.fh-hannover.de> 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