2017-08-21 150 views
0

我需要使用節點圖像將屬性tag ='plan'添加到列tisa_LayoutURL。見下面SQL XML將屬性插入到節點

select @xml = 
    (
      SELECT art.tisa_Code AS [@internal-id], 
       cla.tisa_image1 AS [image], '', 
       cla.tisa_image2 AS [image], '', 
       cla.tisa_image3 AS [image], '', 
       cla.tisa_image4 AS [image], '', 
       art.tisa_LayoutUrl AS [image], 
       addr.tisa_Description AS [description] 
    FROM tisa_article art JOIN 
     tisa_Address addr ON addr.tisa_AddressId = art.tisa_AddressId JOIN 
     tisa_Classifier cla ON cla.tisa_classifierid = addr.tisa_classifierid 
    JOIN 
     Account Acc ON Acc.AccountId=cla.tisa_vendorid 
    FOR XML PATH('offer'), root('realty-feed')) 

我詢問我需要獲取以下信息:

<image>xxxxx.jpg</image> 
<image>xxxx1.jpg</image> 
<image>xxxx2.jpg</image> 
<image>xxxx3.jpg</image> 
<image tag="plan">xxxx4.jpg</image> 

如何修改我的查詢來實現這一目標?

+0

我假設你是在一個SQL Server數據庫的工作? –

回答

1

替換行

art.tisa_LayoutUrl AS [image], 

有:

'plan' AS "image/@tag", 
art.tisa_LayoutUrl AS [image], 
+0

謝謝!它幫助了我! –