PostgreSQL
 sql >> Database >  >> RDS >> PostgreSQL

Selezionare dati specifici da un determinato contenuto XML utilizzando la clausola WHERE

prova questo:

   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= ...