PostgreSQL
 sql >> Base de Dados >  >> RDS >> PostgreSQL

Selecione dados específicos de determinado conteúdo XML usando a cláusula WHERE


tente isso:
   with table1 as (select $$
       -- INSERT YOUR XML HERE --
   $$::xml xml_content)

    select * from (
          select (xpath('value/text()',one_item))[1]::text _value,
                 (xpath('label/text()',one_item))[1]::text _label from (
                    select unnest(xpath($$//select[@ref='/uploaded_form_dc8u7x/city']/item$$
                           ,xml_content)) one_item from table1
                 ) a 
            ) b 
    where _value= ...