Yue Yue - 1 month ago 6
SQL Question

How do I treat a special string as an array and select the second object from it in postgreSQL

I have a column in my table which has values like this

1923195445602;182343;en

or

1830310365602;175824;en;EVENT

Data are splitted by ";"

I want to select the second value of it. My thought is to find a way to treat this string as an array... Or is there a better way?

Please help, thanks!

Answer

you can use select split_part(colname,';',2);

Comments