Riaz I

Riaz I

  • NA
  • 42
  • 5.9k

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

Aug 23 2022 1:20 PM

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)