Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 487F42E0068 for ; Wed, 27 Feb 2008 20:34:46 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72722-10 for ; Wed, 27 Feb 2008 20:34:43 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.189]) by postgresql.org (Postfix) with ESMTP id A5E612E0032 for ; Wed, 27 Feb 2008 20:34:43 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so3800544fka.3 for ; Wed, 27 Feb 2008 16:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=kvZ+ZwXWUIE4isQ6ibZ7cJ3iDWWgH+sX1DK10RD5cmw=; b=fRJIYRfq+1SUet2VaD9IxMCJI2LLzIOvaUdJLTYYQAgi9cftogOk9suu0SZBH3menpJxXl41y12An+0x3UVrddyqCDNJFI6hPNxzAAmTL0PAqlCgulkOUyQldjhTbVGmKkgyg/CDyObU/yeCLHlEeNooTbId7i6ujW5LGAHAg7Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YTFBr50MGd7cpWbFEqdXLOjDirFpYlpj3TUUFlltsN9MYX+KYetABUt57hf6ccwFLXJawRFLSDM30JtUiL1k4JgPcB+NReTE02ejNO2i6nk/PckJzPulObSqX9z5huHtNOCAkTIGUnFc0spaeVsMRrWZVdilxgwAqT+Bcr5brxc= Received: by 10.82.165.13 with SMTP id n13mr3323677bue.16.1204158882157; Wed, 27 Feb 2008 16:34:42 -0800 (PST) Received: by 10.82.186.16 with HTTP; Wed, 27 Feb 2008 16:34:42 -0800 (PST) Message-ID: <758d5e7f0802271634q7d8bbdc0t29cb94e932526f22@mail.gmail.com> Date: Thu, 28 Feb 2008 01:34:42 +0100 From: "Dawid Kuroczko" To: josh@agliodbs.com Subject: Re: Subselects returning array and ANY... Cc: pgsql-sql@postgresql.org In-Reply-To: <200802271611.50928.josh@agliodbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <758d5e7f0802271601m592a932bh5916b10eccecbb4a@mail.gmail.com> <200802271611.50928.josh@agliodbs.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/229 X-Sequence-Number: 30320 On Thu, Feb 28, 2008 at 1:11 AM, Josh Berkus wrote: > Dawid, > > SELECT * FROM foo WHERE t = ANY (SELECT '{x4,5,zzz}'::text[]); > > ERROR: operator does not exist: text = text[] > > HINT: No operator matches the given name and argument type(s). You > > might need to add explicit type casts. > > Drop the second SELECT, I think. > > postgres=# select 'x' = ANY ( '{x,y,z}'::TEXT[] ); > ?column? > ---------- > t Probably I didn't make myself clear enough. :) I know this works (see above two examples). I need to connect two tables, one is: CREATE TEMP TABLE haystack (straw text); INSERT INTO haystack SELECT n FROM generate_series(1,100) AS x(n); CREATE TEMP TABLE needles (id int, straws text[]); INSERT INTO needles VALUES (1, '{10,15,aaa}'); SELECT * FROM haystack WHERE straw = ANY (SELECT straws FROM needles WHERE id=1); ERROR: operator does not exist: text = text[] HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. But you are right, though! I just need to leave off the subselect! Thanks! SELECT h.* FROM haystack h JOIN needles ON straw = ANY (straws); (not exactly what I was looking for, but it works ;))