如何在postgresql的字符串中获取特定字符串
how to get specific string in a string on postgresql
我的table字段中有这种类型的字符串。
type_no
2345-ABC-3210002478
我只想 select 字符串的最后 10 位数字,我希望它是:
type_no_id
3210002478
我如何在 PostgreSQL 中执行此操作?
提前致谢
使用 RIGHT() 获得所需的输出。
SELECT RIGHT('2345-ABC-3210002478', 10) type_no_id
如果使用 table 的列,则遵循以下示例
create table test (type_no varchar(100));
insert into test values ('2345-ABC-3210002478');
SELECT RIGHT(type_no, 10) type_no_id
FROM test
我的table字段中有这种类型的字符串。
type_no
2345-ABC-3210002478
我只想 select 字符串的最后 10 位数字,我希望它是:
type_no_id
3210002478
我如何在 PostgreSQL 中执行此操作?
提前致谢
使用 RIGHT() 获得所需的输出。
SELECT RIGHT('2345-ABC-3210002478', 10) type_no_id
如果使用 table 的列,则遵循以下示例
create table test (type_no varchar(100));
insert into test values ('2345-ABC-3210002478');
SELECT RIGHT(type_no, 10) type_no_id
FROM test