3
Answers

Is there a way I can extract this number with a query?

Riaz I

Riaz I

2y
641
1

I have a column in my PostgreSQL 14 DB that has a PHP-serialised array structure like this:

a:1:{s:6:"host";i:7;}

Is there a way I can extract the integer "7" from this column in a PostgreSQL query? I have tried:

convert_from(log.payload::bytea, 'UTF8')

and

substring(log.payload, '([0-9]{1,2})')

...but neither produce the expected result. The integer can be one or two digit number.

Is there a way I can extract this number with a query?

Answers (3)