From: Michael Lewis <mlewis@entrata.com>
To: David Salisbury <dsalis@ucar.edu>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Arrays and ANY problem
Date: Wed, 25 Sep 2019 14:48:22 -0600
Message-ID: <CAHOFxGpQ6Xk3CiM+FYBopMf97MLmxvhmd22y3WXVG4+a3HTBMA@mail.gmail.com> (raw)
In-Reply-To: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com>
References: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com>
>
> db=# select name from table_name_ds_tmp where ARRAY[categoryid] = ANY (
> select string_to_array( '200,400', ',')::bigint[] );
>
Using either of the below instead, I get the proper result. Why doesn't ANY
work? I do not know.
select name from table_name_ds_tmp where ARRAY[categoryid] <@ ( select
(string_to_array( '200,400', ','))::bigint[] );
select name from table_name_ds_tmp where categoryid = ANY ( ARRAY[ 200,
400]::BIGINT[] );
I used-
drop table if exists pg_temp.table_name_ds_tmp;
create temp table table_name_ds_tmp AS(
SELECT 100::BIGINT AS categoryid, 'one'::VARCHAR AS name UNION ALL
SELECT 200::BIGINT, 'two'::VARCHAR UNION ALL
SELECT 300::BIGINT, 'three'::VARCHAR UNION ALL
SELECT 400::BIGINT, 'four'::VARCHAR
);
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: mlewis@entrata.com, dsalis@ucar.edu
Subject: Re: Arrays and ANY problem
In-Reply-To: <CAHOFxGpQ6Xk3CiM+FYBopMf97MLmxvhmd22y3WXVG4+a3HTBMA@mail.gmail.com>
References: <CAKXTjVmV+mHXvzCKtKuHeooYYObNQhST7eG7kJmUcJy7=1cqTg@mail.gmail.com> <CAHOFxGpQ6Xk3CiM+FYBopMf97MLmxvhmd22y3WXVG4+a3HTBMA@mail.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