0
我有如下一個XML結構:如何編寫選擇查詢以選擇多次出現的DB2中特定的xml節點?
<root>
<firstChild>
<a>
<a1>someText</a1>
<a2>someNumber</a2>
<a>
<a>
<a1>someText1</a1>
<a2>someNumber1</a2>
<a>
<a>
<a1>someText2</a1>
<a2>someNumber2</a2>
<a>
<a>
<a1>someText3</a1>
<a2>someNumber3</a2>
<a>
</firstChild>
</root>
我想寫一個DB2 SQL將返回其具有a1作爲someText1和a2爲someNumber1所有的應用程序ID。
欲瞭解更多信息,我有一個表說應用程序具有application_xml列。該列具有上面所示的所有xml文檔,並針對每個應用程序標識進行存儲。
有人可以請建議。
我試過下面的查詢,但沒有成功。
select XMLQUERY('copy $new := $application_xml
for $i in $new/root/firstChild/a[a1 = "someText1"], $new/root/firstChild/a[a2 = "someNumber1"]
return $new') from application
我明白你的答案。但是,您能否指點我一個DB2 XML查詢的好資源,以便我不用擔心語法問題。 – Sam
您可以從DB2知識中心開始:http://www-01.ibm.com/support/knowledgecenter/SSEPGG_10.5.0/com.ibm.db2.luw.xml.doc/doc/c0023895.html?lang = EN –