From: | Michael Lewis <mlewis(at)entrata(dot)com> |
---|---|
To: | David Salisbury <dsalis(at)ucar(dot)edu> |
Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Arrays and ANY problem |
Date: | 2019-09-25 20:48:22 |
Message-ID: | CAHOFxGpQ6Xk3CiM+FYBopMf97MLmxvhmd22y3WXVG4+a3HTBMA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
>
> 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
);
From | Date | Subject | |
---|---|---|---|
Next Message | Alban Hertroys | 2019-09-25 20:50:03 | Re: Arrays and ANY problem |
Previous Message | David Salisbury | 2019-09-25 20:25:15 | Arrays and ANY problem |