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

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Date: 2017-01-17 08:25:38
Message-ID: o5kkdt$il6$1@blaine.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I recently stumbled over the need to use a wildcard escape character for a condition that makes use of LIKE ANY, something like:

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

so that the underscore wouldn't be treated as a wildard (I can't really change the values _inside_ the array as they are user_provided).

The above throws a syntax error.

So my question is: Is there any way to specify an alternate wildcard escape when using LIKE ANY (..)?

Thomas

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-01-17 12:41:18 Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Previous Message Rich Shepard 2017-01-17 01:11:15 Re: 9.6.1: INSERT with PK as serial