Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 0B21E64315A for ; Mon, 15 Mar 2010 08:28:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 94860-03 for ; Mon, 15 Mar 2010 11:28:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moon.antora.ru (moon.antora.ru [89.111.189.180]) by mail.postgresql.org (Postfix) with ESMTP id 2190A643157 for ; Mon, 15 Mar 2010 08:28:37 -0300 (ADT) Envelope-to: pgsql-sql@postgresql.org Received: from moon.inner.space ([10.1.1.5] helo=moon.antora.ru) by moon.antora.ru with esmtp (Exim 4.67) (envelope-from ) id 1Nr8TJ-00027k-S3 for pgsql-sql@postgresql.org; Mon, 15 Mar 2010 14:28:33 +0300 Received: from [192.168.1.107] [94.233.217.115] by moon.antora.ru (Axigen) with (DHE-RSA-AES256-SHA encrypted) ESMTPSA id 19537F; Mon, 15 Mar 2010 14:28:27 +0300 Message-ID: <4B9E1995.2060008@bankir.ru> Date: Mon, 15 Mar 2010 14:27:17 +0300 From: silly sad User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.5) Gecko/20100111 Thunderbird/3.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: Odd query behavior References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Scan-Signature: 589589833cafb4efd0d40a6ced870cb3 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/74 X-Sequence-Number: 33781 On 03/12/10 18:41, Dan McFadyen wrote: > Hello, > > I've come across an odd situation. I've had access to a database where a > the following happens: > > " SELECT * FROM table WHERE name LIKE 'abc%' " returns 2 rows... > > but... > > " SELECT * FROM table WHERE name IN (SELECT name FROM table WHERE name > LIKE 'abc%') " returns 0 rows... I am sorry if it was already spoken. SELECT name FROM table WHERE name LIKE 'abc%' EXPLAIN SELECT name FROM table WHERE name LIKE 'abc%' EXPLAIN SELECT * FROM table WHERE name IN (SELECT name FROM table WHERE name LIKE 'abc%')