Re: Arrays and ANY problem

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: David Salisbury <dsalis(at)ucar(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Arrays and ANY problem
Date: 2019-09-25 20:50:03
Message-ID: 775E048E-4316-4AFE-B4A7-A25AC79DE002@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> On 25 Sep 2019, at 22:25, David Salisbury <dsalis(at)ucar(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2019-09-25 20:54:49 Re: Arrays and ANY problem
Previous Message Michael Lewis 2019-09-25 20:48:22 Re: Arrays and ANY problem