我正在尝试,但我似乎无法在 Firebird 中的 varchar 末尾获得制表符。有谁知道怎么做吗?
更具体地说:
Select guia, convenio, nome, trim (matricula) from table where guia = '142'
Group by guia, convenio, nome, trim (matricula)
结果
142 | 1 | Name of patient | 111222
142 | 1 | Name of patient | 111222
但是,如果我删除注册字段,这是一个带有选项卡的 varchar(40):
Select guia, convenio, nome, matricula from table where guia = '142'
Group by guia, convenio, nome
结果是:
142 | 1 | nome do paciente
当我发现问题出在注册时:
借助此函数:char_length(matricula)
Select guia, convenio, nome, matricula, Char_Length(matricula) from table where guia = '142'
Group by guia, convenio, nome, matricula
结果:
142 | 1 | nome do paciente | 111222 | 6
142 | 1 | nome do paciente | 111222 | 10
最佳答案
如果您想删除值末尾的制表符,您有多种选择:
使用
TRIM
带有显式字符串trim(trailing ascii_char(9) from theColumn)
9
是制表符。此解决方案假定末尾没有空格和制表符的组合。为了解决之前解决方案的不足,使用
REPLACE
用空格替换制表符然后修剪:trim(trailing from replace(theColumn, ascii_char(9), ' '))
然而,最好的解决方案是通过更新数据和更改应用程序来清理数据,以便这些尾随制表符(和空格)不会最终出现在数据库中。或者,您可以添加一个触发器来为您执行此操作。
关于sql - 从 Firebird 中删除制表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42157862/