PostgreSQL LIKE operator doesn't match hyphen
I've a problem with LIKE operator in PostgreSQL. It does not match patterns that contain the -
character. I've tried to escape these characters using the ESCAPE option, but it still does not work.
Query:
select * from footable where trascrizione like '% [---]is Abraam %';
Sample da开发者_运维问答ta (contents of column trascrizione
):
[---]is Abraam [e]t Ise[---] / ((crux quadrata))
How can I solve this problem?
That pattern would not match because there is no space before [---]is Ambraam
. There is a space in your pattern, between the %
and [
characters, and it's requiring that space to be in your data. Try LIKE '%[---]is Abraam %'
.
Please show the code. I have no problem:
SELECT * FROM a WHERE a LIKE '%-' AND b LIKE '%-%' AND c LIKE '-%';
a | b | c | d | e
------+---+------+---+---
foo- | - | -bar | |
(1 Zeile)
精彩评论