pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joseph S <jks@selectacast.net>
To: pgsql-sql@postgresql.org
Subject: How do I search a two dimensional array?
Date: Mon, 29 Mar 2010 18:17:11 -0400
Message-ID: <hor8t7$13bo$1@news.hub.org> (raw)

I can search a one dimensional array with SELECT value = ANY(array), but 
how do I search  two dimensional array for a particular row?  ANY seems 
to flatten out a two dimensional array.

[local]:playpen=> select 2 = any (ARRAY[[1,7],[4,2]]);
  ?column?
----------
  t
(1 row)

Time: 52.451 ms
[local]:playpen=> select ROW(2,7) = any (ARRAY[[1,7],[4,2]]);
ERROR:  operator does not exist: record = integer
LINE 1: select ROW(2,7) = any (ARRAY[[1,7],[4,2]]);
                         ^
HINT:  No operator matches the given name and argument type(s). You 
might need to add explicit type casts.
[local]:playpen=> select ROW(4,2) = any (ARRAY[[1,7],[4,2]]);
ERROR:  operator does not exist: record = integer
LINE 1: select ROW(4,2) = any (ARRAY[[1,7],[4,2]]);
                         ^
HINT:  No operator matches the given name and argument type(s). You 
might need to add explicit type casts.
[local]:playpen=>
[local]:playpen=>
[local]:playpen=> select ARRAY[2,7] = ANY( ARRAY[[1,7],[4,2],[6,8]]);
ERROR:  operator does not exist: integer[] = integer
LINE 1: select ARRAY[2,7] = ANY( ARRAY[[1,7],[4,2],[6,8]]);
                           ^
HINT:  No operator matches the given name and argument type(s). You 
might need to add explicit type casts.
[local]:playpen=> select ARRAY[1,7]  = any ( ARRAY[[1,7],[4,2],[6,8]]);
ERROR:  operator does not exist: integer[] = integer
LINE 1: select ARRAY[1,7]  = any ( ARRAY[[1,7],[4,2],[6,8]]);
                            ^
HINT:  No operator matches the given name and argument type(s). You 
might need to add explicit type casts.
[local]:playpen=>



Message-ID: <hor8t7$13bo$1@news.hub.org>
Permalink:  ../hor8t7$13bo$1@news.hub.org/
Also on:    postgresql.org/message-id/hor8t7$13bo$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jks@selectacast.net
  Subject: Re: How do I search a two dimensional array?
  In-Reply-To: <hor8t7$13bo$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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