| The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language Reference
by The PostgreSQL Global Development Group Paperback (6"x9"), 454 pages ISBN 9781906966041 RRP £14.95 ($19.95) Sales of this book support the PostgreSQL project! Get a printed copy>>> |
2.2.3 Subscripts
If an expression yields a value of an array type, then a specific element of the array value can be extracted by writing
expression[subscript]
or multiple adjacent elements (an “array slice”) can be extracted by writing
expression[lower_subscript:upper_subscript]
(Here, the brackets [ ] are meant to appear literally.)
Each subscript is itself an expression,
which must yield an integer value.
In general the array expression must be parenthesized, but the parentheses can be omitted when the expression to be subscripted is just a column reference or positional parameter. Also, multiple subscripts can be concatenated when the original array is multidimensional. For example:
mytable.arraycolumn[4] mytable.two_d_column[17][34] $1[10:42] (arrayfunction(a,b))[42]
The parentheses in the last example are required. See section 6.14 Arrays for more about arrays.
| ISBN 9781906966041 | The PostgreSQL 9.0 Reference Manual - Volume 1A - SQL Language Reference | See the print edition |