I have these values
我有这些价值观
'12345/1'
'23456/1'
'34567/1'
But occasionally these are submitted
但偶尔会提交这些内容
'a1234/1'
How can I explicitly return results where the values are all numbers? I currently am doing this
如何在值为全数的情况下显式返回结果?我目前正在这样做
SELECT SID FROM TRACE WHERE SID LIKE '_____%'
Thanks in advance!
提前致谢!
1 个解决方案
#1
0
DB2 doesn't support regular expressions. But, you can do what you want using translate()
:
DB2不支持正则表达式。但是,你可以使用translate()做你想做的事:
where translate(sid, '/', '/0123456789') = '/'
This removes all digits from the string . . . and then checks if you are just left with a single slash.
这将删除字符串中的所有数字。 。 。然后检查你是否只剩下一个斜杠。
#1
0
DB2 doesn't support regular expressions. But, you can do what you want using translate()
:
DB2不支持正则表达式。但是,你可以使用translate()做你想做的事:
where translate(sid, '/', '/0123456789') = '/'
This removes all digits from the string . . . and then checks if you are just left with a single slash.
这将删除字符串中的所有数字。 。 。然后检查你是否只剩下一个斜杠。