0

我在 Oracle 中有以下 sql 查询。

SELECT pr.uuid AS masterproductid, 
            (case 
                when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL THEN 'sellingpoint1'
                when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL THEN 'sellingpoint2'
            END
            ) as testt
  FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM  productvariation prv WHERE  prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')

在这种情况下 - 当“卖点 1”和“卖点 2”都不为空但此查询仅返回卖点 1 时,我也想要“卖点 2”我怎么能得到它?

感谢帮助

4

1 回答 1

0

这将其分为两列:

SELECT pr.uuid AS masterproductid, 
            (case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL
                 THEN 'sellingpoint1'
             end) as testsellingpoint1,
            (case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL
                  THEN 'sellingpoint2'
             END
            ) as testsellingpoint2
  FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM  productvariation prv WHERE  prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')
于 2013-02-22T14:09:43.183 回答