0

I'm trying to extract value from a column containing xml.

here's a snippet from my xml, where i want the value of "fieldscreen.id"

<action id="141" name="Abandonner" view="fieldscreen">
          <meta name="issue.editable">false</meta>
          <meta name="description">Abandonnée</meta>
          <meta name="fieldscreen.id">10102</meta>
          <restrict-to>
            <conditions>
              <condition type="class">

Please help me with the sql where i get only the value of fieldscreen.id from the column. Database- mysql

1

1 Answer 1

2
set @xml:='<action id="141" name="Abandonner" view="fieldscreen">\n<meta name="issue.editable">false</meta>\n<meta name="description">Abandonnée</meta>\n<meta name="fieldscreen.id">10102</meta>\n</action>';
SELECT ExtractValue(@xml, 'action/meta[@name="fieldscreen.id"]');
| ExtractValue(@xml, 'action/meta[@name="fieldscreen.id"]') |
| :-------------------------------------------------------- |
| 10102                                                     |

db<>fiddle here

Sign up to request clarification or add additional context in comments.

4 Comments

Hi Akina, when i run the query for my column in database which has full xml, it gives null result.
@Ritika when i run the query for my column in database which has full xml, it gives null result. Edit my fiddle, insert 3-5 YOUR REAL record values instead of example value, and give new link - 'll look at...
@Ritika 1) Always check for quote chars in string literals, and quote them (double, for example). 2) There is NO entity with the name "fieldscreen.id" in your XML - but there are 6 entities with the name "jira.fieldscreen.id" and more complex paths.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.