mySql WHERE `xml<date>` = '11/21/2010'
i have a mySql database, and it has an field for each entry called xml, which contains XML. i would like to know if there is syntax to 开发者_高级运维select xml values like normal fields.
for example if i wanted to select all entries with the date of 11/21/2010 i try something like this, but the syntax is wrong, since i don't know how to work with xml well in mySql.
SELECT *
FROM `table`
WHERE `xml<date>` = '11/21/2010'
Ideally, I would like to compare it to another field:
SELECT *
FROM `table`
WHERE `xml<date>` != `date`
You can use the ExtractValue function with an XPath expression to get your desired field:
SELECT *
FROM `table`
WHERE ExtractValue(xml,'/a/suitable/xpath/expression') != `date`
精彩评论