How to select XML attribute - Converting MSSQL to MySQL -
i need convert mssql query below mysql. query selects value of "id" attribute out of "page" element in xpath. expect mysql query return 3 rows values 1,2,3 respectively. know how in mysql? please let me know.
declare @inputxml xml set @inputxml = '<pages><page id="1"/><page id="2"/><page id="3"/></pages>' select node.value('@id', 'bigint') id @inputxml.nodes('/pages/page') tempxml (node))
edit: forget said earlier.
courtesy of dave, want @ this:
http://dev.mysql.com/doc/refman/5.1/en/xml-functions.html
(previous answer left in place reference):
mysql doesn't xml. short answer is: "you can't".
the long answer is, depending on context runs in, have few options.
- normalize data proper sql schema, instead of relying on xml inside sql.
- pull xml database plain strings, , xml processing in logic (php, c#, vb, whatever you're using). unfortunately, means can't filter data xpath expressions on database, you'll have pull in all candidate rows , discard ones don't want.
- ditch database altogether (at least part) , store xml files. if storing , retrieving xml files application does, , you're not adding meta-information, database has little no benefit.
Comments
Post a Comment