Re: Arrays and ANY problem

2019-09-30 Thread Andrew Gierth
> "David" == David Salisbury writes: David> I didn't specify the real problem as it's all wrapped up in David> layers and I didn't want to post a "can someone write the query David> for me". The real problem was I have a table with a string David> holding comma separated numbers, and need

Re: Arrays and ANY problem

2019-09-30 Thread David Salisbury
I didn't specify the real problem as it's all wrapped up in layers and I didn't want to post a "can someone write the query for me". The real problem was I have a table with a string holding comma separated numbers, and needed to go to a lookup table and replace each of those numbers with it's cor

Re: Arrays and ANY problem

2019-09-25 Thread Tom Lane
Alban Hertroys writes: >> On 25 Sep 2019, at 22:50, Alban Hertroys wrote: >> You probably meant: >> select name from table_name_ds_tmp where categoryid = ANY ( select >> string_to_array( '200,400', ',')::bigint[] ); > Or rather: > select name from table_name_ds_tmp where categoryid = ANY ( stri

Re: Arrays and ANY problem

2019-09-25 Thread David G. Johnston
On Wed, Sep 25, 2019 at 3:08 PM David Salisbury wrote: > Thanks, > > Unfortunately I believe I need to include a postgres module to get the > "<@" operator, which I have no power to do. This is what I get with that > operator.. > > select name from table_name_ds_tmp where categoryid <@ ANY ( AR

Re: Arrays and ANY problem

2019-09-25 Thread David Salisbury
Thanks, Unfortunately I believe I need to include a postgres module to get the "<@" operator, which I have no power to do. This is what I get with that operator.. select name from table_name_ds_tmp where categoryid <@ ANY ( ARRAY[ 200, 400]::BIGINT[] ); ERROR: operator does not exist: bigint

Re: Arrays and ANY problem

2019-09-25 Thread Alban Hertroys
> On 25 Sep 2019, at 22:50, Alban Hertroys wrote: > > >> On 25 Sep 2019, at 22:25, David Salisbury 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 t

Re: Arrays and ANY problem

2019-09-25 Thread Alban Hertroys
> On 25 Sep 2019, at 22:25, David Salisbury 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

Re: Arrays and ANY problem

2019-09-25 Thread Michael Lewis
> > 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] <@ ( sel

Arrays and ANY problem

2019-09-25 Thread David Salisbury
Perhaps someone can guide me here as I'm having a "moment". :) Not sure why I am getting 0 rows returned here: db=# \d table_name_ds_tmp Column | Type| Modifiers +---+--- categoryid | bigint| name | character varying | d