PostgreSQL LIKE 运算符与连字符不匹配
我在 PostgreSQL 中遇到了 LIKE 运算符的问题。它与包含 -
字符的模式不匹配。我尝试使用 ESCAPE 选项转义这些字符,但它仍然不起作用。
查询:
select * from footable where trascrizione like '% [---]is Abraam %';
示例数据(trascrizione
列的内容):
[---]is Abraam [e]t Ise[---] / ((crux quadrata))
我该如何解决这个问题?
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 data (contents of column trascrizione
):
[---]is Abraam [e]t Ise[---] / ((crux quadrata))
How can I solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该模式不匹配,因为
[---]is Ambraam
之前没有空格。您的模式中%
和[
字符之间有一个空格,并且要求数据中存在该空格。尝试LIKE '%[---]is Abraam %'
。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. TryLIKE '%[---]is Abraam %'
.请出示代码。我没有问题:
Please show the code. I have no problem: