Re: BUG #13747: Like clause ignoring raws with null value

From: Félix GERZAGUET <felix(dot)gerzaguet(at)gmail(dot)com>
To: dtyshecky(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #13747: Like clause ignoring raws with null value
Date: 2015-10-31 10:54:56
Message-ID: CANVwZttG1eETzj0uk9aQ--fFH3w19ZjGzp_hKf-tgF1MTrLX6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, Oct 30, 2015 at 12:08 AM, <dtyshecky(at)gmail(dot)com> wrote:

> I am executing select with like clause on the field X (select * from table
> where x like '%ABC%')
>
> In result I don't receive the raws with null in X column so I have to
> manually state (where X is null or X like ...)
>
> I would expect to receive columns with null.
>

I don't understand your reasons either, but you can achieve what you want
with:

select * from table where coalesce(x, 'ABC') like '%ABC%'

but I find that less clear (and maybe a little bit less performant than)
than:

select * from table where x like '%ABC%' or x is null

--
Félix

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David Gould 2015-10-31 12:18:53 Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower.
Previous Message David Gould 2015-10-31 10:20:51 Re: BUG #13750: Autovacuum slows down with large numbers of tables. More workers makes it slower.