Re: Odd behavior with LIKE?

From: "Tim Barnard" <tbarnard(at)povn(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Odd behavior with LIKE?
Date: 2001-06-11 19:43:09
Message-ID: 023c01c0f2ae$be7f02c0$a519af3f@hartcomm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks. Somehow I missed that :-(

Tim

----- Original Message -----
From: "GH" <grasshacker(at)over-yonder(dot)net>
To: "Tim Barnard" <tbarnard(at)povn(dot)com>
Cc: <pgsql-general(at)postgresql(dot)org>
Sent: Monday, June 11, 2001 12:23 PM
Subject: Re: [GENERAL] Odd behavior with LIKE?

> On Mon, Jun 11, 2001 at 11:00:36AM -0700, some SMTP stream spewed forth:
> > I've noticed that if I don't preceed an underscore character ( _ )
> > with a double backslash ( \\ ), then a select using LIKE
> > ignores the underscore. For example, I have a couple of indexes
> > that end with "_ts" and a few tables that end in "ts":
>
> Quote /usrs-lounge/docs/7.1/user/functions-matching.html#FUNCTIONS-LIKE
> ...
> An underscore (_) in pattern stands for (matches) any single character; a
> percent sign (%) matches any string of zero or more characters.
> ...
> 'abc' LIKE '_b_' true
>
> > select relname from pg_class where relname not like 'pg\\_%' and relname
not like '%\\_pkey' and relname not like '\\_ts';
> >
> > Question is: Why must the underscore character
> > be prefixed with a double-backslash?
>
> It must be escaped because it a special pattern-matching character.
>
>
> gh
>
> > Tim
> >
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message mi 2001-06-11 21:05:51 Re: sysauth-pgsql / pam-pgsql port(s) ...
Previous Message GH 2001-06-11 19:23:02 Re: Odd behavior with LIKE?