'Convert local-name() from MSSQL to MySQL
I'm working on migrating some codes from MSSQL to MySQL, but I don't know the equivalent of local-name()in MySQL.
The original MSSQL code is as followed:
with cte as (select convert(xml,'<Attributes>
<Map>
<entry key="trigger" value = "action">
<value>
<Map>
<entry key=" Processing">
<value>
<Boolean>true</Boolean>
</value>
</entry>
</Map>
</value>
</entry>
</Map>
</Attributes>') as attributes)
select entr.value('@key','nvarchar(100)') AS AttrKey
,entr.value('@value','nvarchar(500)') AS AttrValue
,HasValueElement.value('local-name(.)','nvarchar(100)') AS ValueType
FROM cte a1
cross apply a1.attributes.nodes(N'/Attributes/Map/entry') A(entr)
OUTER APPLY A.entr.nodes(N'value/*') B(HasValueElement)
The output is: AttrKey ||AttrValue ||ValueType Trigger ||Action ||Map
How we can apply similar to local-name() in MySQL to return the ValueType = "Map"? When I tried something like "//*[local-name()]" in MySQL, it returned error.
And what is the "." in "local-name(.)" meaning?
Really appreciate your support.
TIA
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
