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:00:18
Message-ID: 36E6DD61.EFC1B2F4@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

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Reinke 1999-03-10 21:09:56 Re: [HACKERS] Bug on complex subselect (was: Bug on complex join)
Previous Message Jackson, DeJuan 1999-03-10 20:18:15 RE: [HACKERS] Bug on complex subselect (was: Bug on complex join)