How match percent sign in SELECT using LIKE?

From: Dan Lauterbach <danla(at)micromotion(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: How match percent sign in SELECT using LIKE?
Date: 1999-03-10 21:58:01
Message-ID: 36E6EAE8.4F163DA7@micromotion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message secret 1999-03-10 21:59:48 Re: [SQL] Re: How to optimize a query... -- Extreme performance difference, same EXPLAIN
Previous Message Sue Hanen 1999-03-10 21:49:11 Recording Date,Time and UserId when a record is modified