Skip to content
Advertisement

Matching literal percent in h2/postgres?

I have the following value in a db column:

some%thing

I’m using h2 and postgres, but can’t figure out why this query, where I have escaped the % to perform a literal search, is not matching the row highlighted?:

LIKE 'some%thing'

enter image description here

Advertisement

Answer

Because 'value' is a character string literal and not the name of your column. You need to use double quotes instead.

"value" LIKE 'some%hing'

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement