Search Postgresql Archives

Re: How may I keep prepended array items positive?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 31, 2005 at 04:37:39PM -0800, Matthew Peter wrote:
> I would need to prepend a couple array items BUT I
> NEED them to be positive [1:13] instead of [-4:9] for
> instance. 
> 
> How may I keep prepended array items positive? 

You could use array-to-array concatenation instead of prepending
(aka element-to-array concatenation):

test=> SELECT 99 || ARRAY[1, 2, 3];  -- unwanted results
     ?column?     
------------------
 [0:3]={99,1,2,3}
(1 row)

test=> SELECT ARRAY[99] || ARRAY[1, 2, 3];  -- desired results
  ?column?  
------------
 {99,1,2,3}
(1 row)

-- 
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux