我正在搜索如何检查任何字段是否包含 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/