Santosh Kumar
Santosh Kumar

Reputation: 77

Splitting string based on delimiter in mysql

Is there any way to split the following string |RPI;DHCP Letter;IFU;PIL;PCL| into |RPI|;|DHCP Letter|;|IFU|;|PIL|;|PCL|?

Any inputs would be helpful. Thank you.

Upvotes: 0

Views: 217

Answers (1)

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520908

If I read correctly, and the actual strings in your column do not deviate from the data you showed us, then I think we can simply do a blanket replacement of ; with |;| to get the output you want:

SELECT
    REPLACE(col, ';', '|;|') AS new_col
FROM yourTable

Output:

|RPI|;|DHCP Letter|;|IFU|;|PIL|;|PCL|

Demo here:

Rextester

Upvotes: 2

Related Questions