pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Array comparison
3+ messages / 3 participants
[nested] [flat]

* Array comparison
@ 2010-01-08 05:00 ramasubramanian <ramasubramanian.g@renaissance-it.com>
  2010-01-08 16:06 ` Re: Array comparison Rui Carvalho <rui.hmcarvalho@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: ramasubramanian @ 2010-01-08 05:00 UTC (permalink / raw)
  To: pgsql-performance

Hi all,
I want to compare the two arrys in sql, The below example is wrong.
But i want to know how to do that in postgres 8.2.5

SELECT 'x'   WHERE  string_to_array('the,quick,ram,fox', ',')  any (string_to_array('the,quick,lazy ,fox', ','))
Regards,
Ram

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Array comparison
  2010-01-08 05:00 Array comparison ramasubramanian <ramasubramanian.g@renaissance-it.com>
@ 2010-01-08 16:06 ` Rui Carvalho <rui.hmcarvalho@gmail.com>
  2010-01-08 16:36   ` Re: Array comparison Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Rui Carvalho @ 2010-01-08 16:06 UTC (permalink / raw)
  To: ramasubramanian <ramasubramanian.g@renaissance-it.com>; +Cc: pgsql-performance

Hi

well it's pretty simple

if you want to see if there are elements in common then instead of "any" use
"&&"
if you want to see if they are equal just use " = " that will five you true
or false



 you can check array functions in here
http://www.postgresql.org/docs/8.2/static/functions-array.html


On Fri, Jan 8, 2010 at 5:00 AM, ramasubramanian <
ramasubramanian.g@renaissance-it.com> wrote:

>  Hi all,
> I want to compare the two arrys in sql, The below example is wrong.
> But i want to know how to do that in postgres 8.2.5
>
> SELECT 'x'   WHERE  string_to_array('the,quick,ram,fox', ',')  any
> (string_to_array('the,quick,lazy ,fox', ','))
> Regards,
> Ram
>
>
>
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Array comparison
  2010-01-08 05:00 Array comparison ramasubramanian <ramasubramanian.g@renaissance-it.com>
  2010-01-08 16:06 ` Re: Array comparison Rui Carvalho <rui.hmcarvalho@gmail.com>
@ 2010-01-08 16:36   ` Merlin Moncure <mmoncure@gmail.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Merlin Moncure @ 2010-01-08 16:36 UTC (permalink / raw)
  To: Rui Carvalho <rui.hmcarvalho@gmail.com>; +Cc: ramasubramanian <ramasubramanian.g@renaissance-it.com>; pgsql-performance

On Fri, Jan 8, 2010 at 11:06 AM, Rui Carvalho <rui.hmcarvalho@gmail.com> wrote:
> Hi
>
> well it's pretty simple
>
> if you want to see if there are elements in common then instead of "any" use
> "&&"
> if you want to see if they are equal just use " = " that will five you true
> or false

you also have the option of expanding the array into a set and using
standard query techniques.  w/8.4, you can use the built in
unnest()...for earlier versions you have to create it yourself
(trivially done):

http://archives.postgresql.org/pgsql-patches/2008-03/msg00308.php

merlin



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-01-08 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-01-08 05:00 Array comparison ramasubramanian <ramasubramanian.g@renaissance-it.com>
2010-01-08 16:06 ` Rui Carvalho <rui.hmcarvalho@gmail.com>
2010-01-08 16:36   ` Merlin Moncure <mmoncure@gmail.com>

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