Parse text field from query

Parse text field from query

am 31.03.2011 13:49:23 von ciglesias

--------------050401070101030409090100
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Hello,

I have this field in a table from my database that contains a lot of=20
information and I would like to extract only a little bit of it.
I have to parse it but need to do it directly in the sql query, =BFdo you=
=20
know what kind of function I have to use, or how?

This is an example of the field (i need the 1 in cpu data):

|=20
=20
|

Thanks.

--------------050401070101030409090100--

Re: Parse text field from query

am 31.03.2011 18:35:03 von Dan Nelson

In the last episode (Mar 31), Carlos Fernndez Iglesias said:
> I have this field in a table from my database that contains a lot of
> information and I would like to extract only a little bit of it. I have
> to parse it but need to do it directly in the sql query, do you know what
> kind of function I have to use, or how?

Since your data is well-formed XML, you can use mysql's ExtractValue()
function:

mysql> select extractvalue(f,"/TEMPLATE/CPU") from t;
+---------------------------------+
| extractvalue(f,"/TEMPLATE/CPU") |
+---------------------------------+
| 1 |
+---------------------------------+
1 row in set (0.01 sec)

See http://dev.mysql.com/doc/refman/5.5/en/xml-functions.html for more info.

> This is an example of the field (i need the 1 in cpu data):
>
> |
>
> |


--
Dan Nelson
dnelson@allantgroup.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org