If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > XML ExtractValue as multiple rows

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-10-09, 07:29
chamonix chamonix is offline
Registered User
 
Join Date: Aug 2009
Posts: 1
XML ExtractValue as multiple rows

I want to have the results of this select as multiple rows NOT as a single space-delimited string.

SET @xml = '<?xml version="1.0" encoding="UTF-8"?>
<matchmaker_data>
<Models><model display_name="MyModel1" id="1" thumb="/images/MyModel1.jpg">
</model><model display_name="MyModel2" id="2" thumb="/images/MyModel2.jpg">
</model>
</Models>
</matchmaker_data>';


SELECT
ExtractValue(@xml, '//matchmaker_data/Models/model/@display_name') AS model,
ExtractValue(@xml, '//matchmaker_data/Models/model/@thumb') AS thumb;


The reult I get now:
+----------------------------------------------------------------+
| model | thumb |
+----------------------------------------------------------------+
| MyModel1 MyModel2 | /images/MyModel1.jpg /images/MyModel2.jpg |
+----------------------------------------------------------------+



Desired result:

+---------------------------------+
| model | thumb |
+---------------------------------+
| MyModel1 | /images/MyModel1.jpg |
+---------------------------------+
| MyModel2 | /images/MyModel2.jpg |
+---------------------------------+

Thanks in advance
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On