mySQL XML表如何查询和取回数据

时间:2018-12-12 10:23:34

标签: mysql xml

我有一个XML文件,在MySQL(5.7)中另存为BLOB 看起来像这样(我更改了一些值,因为它是有效的数据……)

    <?xml version="1.0" encoding="utf-8"?>
<BarcodeList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://templates.xxxxx.com/v_1_13/barcodelist.xsd" barcodeListID="2017-10-02" barcodeListDescription="Barcodelist complete" generationDate="2018-12-07T13:52:30+01:00" supplierID="xxxxx" supplierName="Company">
  <Clientgroups>
    <clientgroup clientgroupID="0" />
  </Clientgroups>
  <Articles>
    <Article articleID="51082570" articleName="51082570 Article">
      <Configuration>
        <Feature selectedValue="7391899825700" templateID="EanCode" />
      </Configuration>
    </Article>
    <Article articleID="31083687" articleName="31083687 Article">
      <Configuration>
        <Feature selectedValue="7391899836874" templateID="EanCode" />
      </Configuration>
    </Article>
    <Article articleID="31083684" articleName="31083684 Article">
      <Configuration>
        <Feature selectedValue="7391899836843" templateID="EanCode" />
      </Configuration>
    </Article>
    <Article articleID="SLC" articleName="SLC Box">
      <Configuration>
        <Feature selectedValue="785810980338" templateID="UpcCode" />
        <Feature selectedValue="8.60" templateID="Radius" />
        <Feature selectedValue="14.2" templateID="Diameter" />
        <Feature selectedValue="-9.00" templateID="Power" />
      </Configuration>
</Article>
</Articles>

现在,我将必须通过templateID =“ UpcCode”进行搜索(如您在文章ArticleID = SLC中所找到的那样) 当找到该值时,我将必须取回以下值: ArticleId templateId“半径” templateId“直径” templateId“ Power”

我从以下内容开始:

Select 
CONVERT(extractvalue(Data, 'Articles/Article/Configuration/Feature[@selectedValue]') Using UTF8) as Barcode from myTable;

但是我没有得到任何信息... THX提前提供所有帮助

0 个答案:

没有答案