Dmitriy
Dmitriy

Reputation: 133

Extract numbers from a string in Informix

There are strings in my table as follows:

select '1. name 1' from dual union all
select '2. name 2' from dual union all
select '11. name 3' from dual union all
select '12. name 4' from dual

I need to extract the first numbers:

1 2 11 12

Upvotes: 1

Views: 735

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269503

IBM claims that Informix supports substring_index(). If so:

select substring_index(col, '.', 1)

This doesn't exactly get the first number. It returns the first part of the string before the '.', which appears to be the same thing.

Upvotes: 1

Related Questions