Home >Database >Mysql Tutorial >How to Extract Attribute Values from XML Data in SQL Using XQuery?
SQL: Accessing Attribute Values from XML Data
In SQL, accessing the value of an attribute in an XML datatype can be achieved through XQuery. This allows you to query and manipulate XML data efficiently.
To retrieve the value of the language attribute in the provided XML:
You can use the following XQuery expression:
This expression specifies:
To use this expression in your SQL statement, you can modify your query as follows:
This query will return the value of the language attribute as a string.
Example:
Output:
You can also use XQuery to process XML data from a table, as demonstrated in the following example:
Output:
The above is the detailed content of How to Extract Attribute Values from XML Data in SQL Using XQuery?. For more information, please follow other related articles on the PHP Chinese website!