pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alban Hertroys <haramrae@gmail.com>
To: David Salisbury <dsalis@ucar.edu>
Cc: pgsql-general@postgresql.org
Subject: Re: Arrays and ANY problem
Date: Wed, 25 Sep 2019 22:50:03 +0200
Message-ID: <775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com> (raw)
In-Reply-To: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com>
References: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com>


> On 25 Sep 2019, at 22:25, David Salisbury <dsalis@ucar.edu> wrote:
> db=# select name from table_name_ds_tmp where ARRAY[categoryid] = ANY ( select string_to_array( '200,400', ',')::bigint[] );
>  name 
> ------
> (0 rows)

You are comparing two arrays for equality. Since the left-hand array has only 1 item and the right-hand one has two, there’s not much equality between them.

You probably meant:
select name from table_name_ds_tmp where categoryid = ANY ( select string_to_array( '200,400', ',')::bigint[] );


Alban Hertroys
--
There is always an exception to always.









view thread (9+ messages)  latest in thread

Message-ID: <775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com>
Permalink:  ../775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com/
Also on:    postgresql.org/message-id/775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: haramrae@gmail.com, dsalis@ucar.edu
  Subject: Re: Arrays and ANY problem
  In-Reply-To: <775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com>
  References: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com> <775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com>

* 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