mysql> select description from devices where id=172;
+--------------------------------------------------------------------------------+
| description |
+--------------------------------------------------------------------------------+
| Fault: 'HYD OIL TEMP HIGH' from 'Controller' of type 'SYSTEM' with code '1003' |
+--------------------------------------------------------------------------------+
1 row in set (0.01 sec)
以上是我在数据库中有记录的模式。我试图将它们分成多个列,就像这样只是为了运行报告。
+---------+------------------------+--------------+---------+---------+
| status | description | device | system | code |
+---------+------------------------+--------------+---------+---------+
| Fault | HYD HYD OIL TEMP HIGH | controller | SYSTEM | 1003 |
+---------+------------------------+--------------+---------+---------+
我知道我正在做的上述事情更糟。我不想更改 ETL 以运行一次性报告。这是我尝试过的。
mysql> select substr(description, 1, locate(":", description)-1) as status from devices where id=172;
+--------+
| status |
+--------+
| Fault |
+--------+
1 row in set (0.00 sec)
该数据库位于亚马逊 RDS 之上。所以我不能使用lib_mysqludf_preg。我只能做普通的SQL。帮助表示赞赏。谢谢。