Escape string for LIKE op

From: Robert James <srobertjames(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Escape string for LIKE op
Date: 2013-08-15 20:16:04
Message-ID: CAGYyBggb1uvuFRBE4=AJaUtNhohU2qFfaUT4iYXAta6_YpFkWw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

How can I escape a string for LIKE operations?

I want to do:

SELECT * FROM t WHERE a LIKE b || '%'

But I want be to interpreted literally. If b is 'The 7% Solution', I
don't want that '%' to be wildcard. I can't find an appropriate
function to escape it and any other potential wildcards for LIKE
clauses.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Darren Duncan 2013-08-15 20:18:52 Re: Immediate Constraints
Previous Message Andrew Berman 2013-08-15 19:38:02 Re: Streaming Replication Randomly Locking Up