如何在 MySQL 上分隔获取的数据记录?

How do I delimit a fetched data record on MySQL?

我有一列 returns 管道分隔记录如下:

'fromState=A|Count=5|highLimit=B|status=C|presentValue=D|alarmValue=E'

有没有办法将其作为更格式化的输出,例如:

'fromState=A
Count=5
highLimit=B
status=C
presentValue=D
alarmValue=E'

  1. 管道被替换
  2. 每个值都在一个新行上(可选)

使用mysql

的字符串替换功能
SELECT REPLACE('www.mysql.com', 'w', 'Ww');
        -> 'WwWwWw.mysql.com'

或查看您可能需要的另一个功能:https://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

在你的情况下,你可能想要替换 |使用 \n 或 \r.

SELECT REPLACE(列, '|', '\r');