我有这个查询:
select f.n, t.l, grp.n, cat.n, col.n, col_value
from fc
inner join f on f.idfc = fc.idfc
inner join t on t.idf = f.idf
inner join grp on grp.idt = t.idt
inner join cat on cat.idgrp = grp.idgrp
inner join col on col.idcat = cat.idcat
inner join col_value on col_value.idcol = col.idcol
for xml auto, root('fc')
;
它返回这个 xml:
<fc>
<f n="341.11.7">
<t l="A">
<grp n="ID">
<cat n="10">
<col n="R">
<col_value col_value="341" />
</col>
<col n="S">
<col_value col_value="11" />
</col>
<col n="H">
<col_value col_value="7" />
</col>
</cat>
</grp>
</t>
</f>
</fc>
但我需要 col_value 元素必须如下所示:
<col_value>341</col_value>
那么,如何修改查询以达到以下结果?
<fc>
<f n="341.11.7">
<t l="A">
<grp n="ID">
<cat n="10">
<col n="R">
<col_value>341</col_value>
</col>
<col n="S">
<col_value>11</col_value>
</col>
<col n="H">
<col_value>7</col_value>
</col>
</cat>
</grp>
</t>
</f>
</fc>
谢谢大家。查尔斯。