Обсуждение: How match percent sign in SELECT using LIKE?

Поиск
Список
Период
Сортировка

How match percent sign in SELECT using LIKE?

От
Dan Lauterbach
Дата:
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