From: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: can someone explain confusing array indexing nomenclature |
Date: | 2007-02-16 08:34:42 |
Message-ID: | 200702161034.43399.achill@matrix.gatewaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Στις Πέμπτη 15 Φεβρουάριος 2007 18:55, ο/η chrisj έγραψε:
> Thanks Achilleas,
>
> I see what you are saying, but if we consider just the index "[2]" for a
> moment,
> it means something different depending upon the context (in one case it
> means "2" and in the other case it means "1:2") and the context is
> determined by the format of indexes on other dimensions.
>
> I believe I understand....but incredibly confusing.
>
Now that i think about it again, i speculate that the [2] is discarded.
> - chris
>
> Achilleas Mantzios wrote:
> > Ξ£ΟΞΉΟ Ξ�Ξ΅ΟΞ¬ΟΟΞ· 14 ΦΡβΟΞΏΟ
Ξ¬ΟΞΉΞΏΟ 2007 21:31, ΞΏ/Ξ· chrisj
ΞΞ³ΟΞ±ΟΞ΅:
> >> given the following table:
> >>
> >> protocal2=> select * from sal_emp ;
> >> name | pay_by_quarter | schedule
> >> -------+---------------------------+------------------------------------
> >>--- ---- Bill | {10000,10000,10000,10000} |
> >> {{meeting,lunch},{training,presentation}}
> >> Carol | {20000,25000,25000,25000} |
> >> {{breakfast,consulting},{meeting,lunch}}
> >> (2 rows)
> >>
> >> why do the following two queries yield different results??
> >>
> >> protocal2=> SELECT schedule[1][2] FROM sal_emp WHERE name = 'Bill';
> >> schedule
> >> ----------
> >> lunch
> >> (1 row)
> >>
> >> protocal2=> SELECT schedule[1:1][2] FROM sal_emp WHERE name = 'Bill';
> >> schedule
> >> -------------------
> >> {{meeting,lunch}}
> >> (1 row)
> >
> > The [n:m] notation denotes a slice of the array (not element).
> > So schedule[1][2] is the Array element on 2nd col of 1st row,
> > while schedule[1:1][2] could mean
> > the second row of the subarray schedule[1:1][1:2].
> > So these two are foundamentally different things.
> > In my 7.4 even if you gave
> > SELECT schedule[1:1][888] FROM sal_emp WHERE name = 'Bill';
> > you would still get {{meeting,lunch}} as a result.
> > (Right or wrong is another story).
> > Anyway the first time you query for a "text",
> > the second time you query for a "text[]", so you should expect
> > different results.
> > --
> > Achilleas Mantzios
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/docs/faq
--
Achilleas Mantzios
From | Date | Subject | |
---|---|---|---|
Next Message | Ezequias Rodrigues da Rocha | 2007-02-16 12:09:52 | Re: Retrieving 'Credit' when 'C' |
Previous Message | Walter Cruz | 2007-02-15 22:59:58 | Re: "for SELECT DISTINCT, ORDER BY expressions must appear in select list" - is that the standart or a limitation of postgresql? |