X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9887C5E46EF for ; Sun, 15 Aug 2004 15:56:12 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69138-06 for ; Sun, 15 Aug 2004 18:56:06 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 06B2B5E46D2 for ; Sun, 15 Aug 2004 15:56:06 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A3D263527D; Sun, 15 Aug 2004 11:56:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id A1F4735252; Sun, 15 Aug 2004 11:56:07 -0700 (PDT) Date: Sun, 15 Aug 2004 11:56:07 -0700 (PDT) From: Stephan Szabo To: Traci Sumpter Cc: pgsql-sql@postgresql.org Subject: Re: LIKE '%%' does not return NULL In-Reply-To: Message-ID: <20040815115410.B86649@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/136 X-Sequence-Number: 18633 On Wed, 11 Aug 2004, Traci Sumpter wrote: > A team developer has chosen the lazy way of not checking if a variable > exists on his PHP page and has code which produces the following SQL > > SELECT * FROM mytable where myfield ilike '%%' > > I have noticed that this statement does not return null or empty myfield > records. It should not return true for NULLs but should for empty fields (which it does AFAICS). If you want to get the NULLs as well you'll need to explicitly OR myfield is NULL.