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):
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):
>
> |
>
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/hosts
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/exports
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/fstab_h ead_extra
> /srv/cloud/images/carlos_iglesias/cluster_benchmark_kvm/clus ter_head_context/sge_conf.sh
> /srv/cloud/images/carlos_iglesias/cluster_benchmark_kvm/clus ter_head_context/ssh_config_root
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/root_id _rsa
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/root_id _rsa.pub
> /srv/cloud/images/carlos_iglesias/cluster_benchmark_kvm/clus ter_head_context/ssh_config_user
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/user_id _rsa
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/user_id _rsa.pub
> /srv/cloud/cluster_deploys/benchmak-kvm_clusterfiles/user_ex t.pub]]>
LY>
DISK>
> LAN
> kvm]]>
> RUNNING_VMS]]>
> "kvm"]]>
> |
--
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