• MySQL操作XML格式字段


    参考:https://blog.csdn.net/hejiajunhs/article/details/84487945

    -- Example #E1
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/name' ) AS VALUE;
    
    
    -- Example #E2
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/*/*/name' ) AS VALUE;
    
    
    -- Example #E3
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/child::*' ) AS VALUE;
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/descendant::*' ) AS VALUE;
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/parent::*' ) AS VALUE;
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/name/ancestor::*' ) AS VALUE;
    SELECT extractValue ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/url/self::*' ) AS VALUE;
    
    
    -- Example #E4
    SELECT extractValue ( '<book><title>SQL:1999</title><author><initial>J</initial><surname>Melton</surname></author></book>', '/book/author/surname[self:text()>="Melton"]' ) AS VALUE;
    
    
    -- Example #U1
    SELECT UpdateXML ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/name', 'GG' ) AS VALUE
    
    
    -- Example #U2
    SELECT extractvalue ( UpdateXML ( '<sites><site><name>Google</name><url>www.google.com</url></site></sites>', '/sites/site/name', '<name>GG</name>' ), '/sites/site/name' ) AS value;
    
    
  • 相关阅读:
    开始几天的基本学习
    从这个博客开始我的机器学习深度学习之路
    剑指Offer:面试题3——二维数组中的查找(java实现)
    HIVE配置文件
    C++ 之旅:前言
    leetcode 349:两个数组的交集I
    python学习(三):matplotlib学习
    python学习(二):python基本语法
    Android环境搭建
    LeetCode:237
  • 原文地址:https://www.cnblogs.com/DJOSIMON/p/16199163.html
Copyright © 2020-2023  润新知