Search code examples
postgresqlescaping

How to find in postgres strings like %'%


I need to search in my column strings which contains '

select * from app_user au where au.last_name like '%'%'

but something like that gives me

SQL Error [42601]: Unterminated string literal started at position 55

I tried also '%\'%', but it's not working too, how to escape ' in postgres?


Solution

  • To escape ', you need to add it twice. Use '' to resolve it.

    select * from app_user au where au.last_name like '%''%'