How match percent sign in SELECT using LIKE? - Mailing list pgsql-sql

From Dan Lauterbach
Subject How match percent sign in SELECT using LIKE?
Date
Msg-id 36E6EAE8.4F163DA7@micromotion.com
Whole thread Raw
Responses Re: [SQL] How match percent sign in SELECT using LIKE?
List pgsql-sql
How do I match '%' in a SELECT query using LIKE predicate?   For
example, to query for DocNo's
containing string 'EW%':

SELECT * FROM XXXX WHERE DocNo LIKE '%EW%%';

PostgreSQL wants to treat the '%' in 'EW%' as a wildcard.  I've tried
escaping the '%' using '\%',
'%%'.   The SQL-92 standard provides for this using the ESCAPE keyword:

SELECT * FROM XXXX WHERE DocNo LIKE '%EW#%%' ESCAPE '#';

However, PostgreSQL doesn't appear to support the ESCAPE keyword.  Any
suggestions would be
greatly appreciated.  I'm using PostgreSQL v6.2.1.

Thanks,
Dan Lauterbach



pgsql-sql by date:

Previous
From: secret
Date:
Subject: Re: [SQL] Re: How to optimize a query... -- Extreme performance difference, same EXPLAIN
Next
From: "Joe Shevland"
Date:
Subject: Stored Procedure FAQ