gpt4 book ai didi

MYSQL 提取值

转载 作者:行者123 更新时间:2023-11-29 18:18:17 24 4
gpt4 key购买 nike

我有以下 xml

  <ns8:vehicles>
<ns8:vehicle vinNumber="asdaqwe" model="lambda" make="xdeee">
<ns8:registration number="e123asdz23" date="2016-07-22"/>
<ns8:usage type="Passenger"/>
</ns8:vehicle>
</ns8:vehicles>

并尝试在查询中使用 extractValue 获取元素 vinNumber 和注册号所以我正在做这样的事情:

select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration')
select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration number')
select ExtractValue(databasexmlfield, '//ns8:vehicle//ns8:registration::number')

这些作品都不会返回 xpath 错误或返回 0 数据。我该如何让它工作?

当 xml 像这样呈现时它就可以工作:

<holder id="1">
<title>Mr</title>

所以当我输入 select ExtractValue(databasexmlfield,'//holder//title') 时它打印先生。Mysql版本最新5.5

最佳答案

尝试:

SELECT
ExtractValue(@`xml`, '//ns8:vehicle/attribute::vinNumber'),
ExtractValue(@`xml`, '//ns8:vehicle/ns8:registration/attribute::number');

参见db-fiddle .

关于MYSQL 提取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46815209/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com