Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Kellerer <spam_eater(at)gmx(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Date: 2017-01-17 12:41:18
Message-ID: 25377.1484656878@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thomas Kellerer <spam_eater(at)gmx(dot)net> writes:
> So my question is: Is there any way to specify an alternate wildcard escape when using LIKE ANY (..)?

No, not with ESCAPE. [ manfully resists temptation to run down SQL
committee's ability to design composable syntax ... oops ]

You could do what PG does under the hood, which is to run the pattern
through like_escape():

select *
from some_table
where name like any (array[like_escape('foo_bar%', '/'),
like_escape('bar_foo%', '/')]);

If that seems too verbose, maybe build a function to apply like_escape
to each member of an array.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2017-01-17 12:45:34 Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Previous Message Thomas Kellerer 2017-01-17 08:25:38 Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)