Postgresql : Search field contain tab character.(有 LIKE)

标签 postgresql

我正在搜索如何检查任何字段是否包含 TAB 字符。

阅读后this post ,我尝试使用这个命令:

SELECT id FROM account WHERE description LIKE '%\t%';

但它会返回所有包含“t”字符的字段。

你有什么解决方案来表示 TAB 字符吗?

最佳答案

在 SQL 中,没有像 \t 这样的字符“转义”。您可以为此使用 chr() 函数:

select id
from account
where description LIKE '%'||chr(9)||'%'

在这种情况下,我更喜欢 strpos 函数,因为我认为它使意图更清晰

select id
from account
where strpos(description, chr(9)) > 0

关于Postgresql : Search field contain tab character.(有 LIKE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27616902/

相关文章:

python - Django 模型和 PostgreSQL 货币类型

json - 为什么 PostgreSQL 在 jsonb 效率更高时保留 json 字段?

regex - 删除 PostgreSQL 中的所有 Unicode 空格分隔符?

json - PostgreSQL 转义 JSON 字符串

Java 服务器和 PostgreSQL 连接

java - 将 Map<Enum, Enum> 存储为字符串

postgresql - 如果多个,使用 sequelize 绑定(bind)参数会失败

sql - PostgreSQL 错误 : payload string too long

postgresql - 在插入 : column reference "score" is ambiguous

python - Django(postgresql)+ lighttpd。线程和 python 的 postgresql 驱动程序有什么问题吗?