Re: LIKE '%%' does not return NULL

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Traci Sumpter <Traci(dot)Sumpter(at)opus(dot)co(dot)nz>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: LIKE '%%' does not return NULL
Date: 2004-08-15 18:56:07
Message-ID: 20040815115410.B86649@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Finner 2004-08-15 19:17:49 Re: LIKE '%%' does not return NULL
Previous Message Thomas Wegner 2004-08-14 22:20:57 Re: tablefunc's in 8.0 Beta Win32 - where?