Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDEDX-0005f9-Ru for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2019 20:48:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDEDW-0008U1-GN for pgsql-general@arkaria.postgresql.org; Wed, 25 Sep 2019 20:48:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDEDV-0008Kh-W6 for pgsql-general@lists.postgresql.org; Wed, 25 Sep 2019 20:48:54 +0000 Received: from mail-yw1-xc2f.google.com ([2607:f8b0:4864:20::c2f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDEDS-0000Lr-Ou for pgsql-general@postgresql.org; Wed, 25 Sep 2019 20:48:53 +0000 Received: by mail-yw1-xc2f.google.com with SMTP id u187so2568454ywa.11 for ; Wed, 25 Sep 2019 13:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=entrata-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7bKmIn6qkPfmcbtur4SsPt+O20k1lzl0fuNvyGkoJVY=; b=bMtTBsHTKb8hacauKtRGSs517rtDUe+FbmetQl8KMagG9GO/s3PXpdbj3p9lv/kikx bZb+qHIZYq4vXHiwldSn33Tb3QkVZ03o5np/BfgF+/zGFYHwzm5HQvZyAq8OK50LMmsv c/ulMtGPTXUVYyy63MajUwTfvWmFxTQQ0TREQHvG0lrunEKD6hlGuv8ctGA5XamuovqS apHugEqQdNYGFdaRFWx8QffqS35dpvXtdHwH+haSs7I97ExCJ9HL6/MXYqlr1a/PNsMw +3g03wqvcMCqpdOg9qMxN7+3gnIco0qVKTmWgwMhVdJDZQQUhne45d3f2yDtXg6j/Aj0 C6pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7bKmIn6qkPfmcbtur4SsPt+O20k1lzl0fuNvyGkoJVY=; b=Y8iXS5P4cZtvMKb74lgVE7MF9o5OVwNfZ5/10TNUq4cACmboTRIKVhGNPmyKjpoMEt sXuHiouREFztBM9sQjcYrIhxreU1scDlvIEHTme4x4PW0a2Jq5y9aD2cYRVLSD2E06TA WRDa1MjLofxEaN4Hn6ugTjkUPYRnijV29F6C4PDz7s2F3u79ihpWlkDgnfvmfChICdQw Dxp5t/V4WeT0mbX53T3RFvT74qnGvcpib9vNGx7womh1XLJan5Q6IM5hnpBq/C3O3NW4 nlZO+VvTTV3ysRV0nXsgS2+1FJM596p4A0pLfEpKNeIKBpLlDxCYoka1AQ6Ndn0SAU31 RYFQ== X-Gm-Message-State: APjAAAUy8RfF8e9yzvyvi6+OcbYjypX5KdG4fdIyTcdqy+eX26nyXWI4 g3sKZhxHdx4lf2BaJ6FJQRj6VRdp63uiqCcd+8tbwQ== X-Google-Smtp-Source: APXvYqxLDdg4DJkQajbBP8bXbYrmjZ9xHKb5mppHQCZRinNrNAeya4dTTP3nhq1KlrYHfAV74Vezdv9lwBFxYJoJ+gM= X-Received: by 2002:a0d:d9d3:: with SMTP id b202mr42158ywe.63.1569444528631; Wed, 25 Sep 2019 13:48:48 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Michael Lewis Date: Wed, 25 Sep 2019 14:48:22 -0600 Message-ID: Subject: Re: Arrays and ANY problem To: David Salisbury Cc: pgsql-general Content-Type: multipart/alternative; boundary="0000000000009fce58059366c753" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --0000000000009fce58059366c753 Content-Type: text/plain; charset="UTF-8" > > 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 ); --0000000000009fce58059366c753 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
db=3D# select = name from table_name_ds_tmp where ARRAY[categoryid] =3D 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] <@ ( se= lect (string_to_array( '200,400', ','))::bigint[] );=C2=A0<= /div>
select name from table_name_ds_tmp where categoryid =3D ANY ( ARR= AY[ 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::BI= GINT, 'four'::VARCHAR
);
--0000000000009fce58059366c753--