Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql:搜索字段包含制表符。(带LIKE)_Postgresql - Fatal编程技术网

Postgresql:搜索字段包含制表符。(带LIKE)

Postgresql:搜索字段包含制表符。(带LIKE),postgresql,Postgresql,我正在搜索如何检查任何字段是否包含制表符 阅读后,我尝试使用以下命令: SELECT id FROM account WHERE description LIKE '%\t%'; 但它会返回所有包含“t”字符的字段 您有任何表示制表符的解决方案吗?在SQL中,没有像\t这样的字符“转义”。您可以使用chr()函数执行以下操作: select id from account where description LIKE '%'||chr(9)||'%' 在本例中,我更喜欢strpos函数,因为

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

阅读后,我尝试使用以下命令:

SELECT id FROM account WHERE description LIKE '%\t%';
但它会返回所有包含“t”字符的字段

您有任何表示制表符的解决方案吗?

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

select id
from account
where description LIKE '%'||chr(9)||'%'
在本例中,我更喜欢
strpos
函数,因为我认为它使意图更加清晰

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

你必须使用文字标签

 SELECT id FROM account WHERE description LIKE '%   %';
在psql中键入ctrl-V,然后键入TAB以输入选项卡。在其他环境中,还有其他方法可以输入文字选项卡


或者,您可以使用转义字符串语法:
e“%\t%”
,或者八进制转义
e“%\011%”
,我参加这个聚会已经很晚了,但今天研究过这个问题后,我发现您也可以使用正则表达式

SELECT id FROM account WHERE description ~ '\t';

或者您可以使用十六进制值:0x09:D…确实可以,postgresql在内部将类似的表达式转换为正则表达式。该问题要求使用LIKE解决方案,但接受的答案使用不同的方法。如果您有其他可能打开文件并将选项卡转换为空格的编码人员,则在查询中使用文字选项卡是危险的。