开发者

PostgreSQL LIKE operator doesn't match hyphen

开发者 https://www.devze.com 2023-03-29 06:54 出处:网络
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.

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)
0

精彩评论

暂无评论...
验证码 换一张
取 消