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 > Query problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-28-07, 05:29
ghoprat ghoprat is offline
Registered User
 
Join Date: Nov 2007
Posts: 4
Query problem

Hi

One of my output columns contain xml data .My requirement is I want to write a query which will give an output of a particular portion of the xml data .
Say within the xmldata I have <me>wiqwn</me>.I want only this part as the output.
Can u suggest how should be the query for that be ?
Reply With Quote
  #2 (permalink)  
Old 11-28-07, 08:33
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
select '<me>wiqwn</me>' as i_found_it
  from daTable
 where thirdcolumn like '%<me>wiqwn</me>%'
Attached Thumbnails
Query problem-find-x.jpg  
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-28-07, 08:45
ghoprat ghoprat is offline
Registered User
 
Join Date: Nov 2007
Posts: 4
hi

thanks.
But what i actually wanted is not select '<me>wiqwn</me>' because i dont know the "wiqwn" and this will be variable every time .
I have the fixed opening and closing tag i want the contents within it as output .

Thanks in advance.
Reply With Quote
  #4 (permalink)  
Old 11-28-07, 09:05
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
LOCATE('foo',daColumn) gives you the starting position of 'foo' in daColumn

you'll need two of these (one each for the opening and closing tags) together with some arithmetic in a SUBSTRING call
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 11-30-07, 07:36
ghoprat ghoprat is offline
Registered User
 
Join Date: Nov 2007
Posts: 4
Hi

Can anyone provide me with a sample query regarding my request .

Many thanks in advance.
Reply With Quote
  #6 (permalink)  
Old 11-30-07, 08:19
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
See post 4 for the answer.
Everything you need is there!
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 11-30-07, 11:05
ghoprat ghoprat is offline
Registered User
 
Join Date: Nov 2007
Posts: 4
Hi

Couldnt figure out still .
Where to place the 2nd locate a nd how to plug them in a query.
please help
Reply With Quote
  #8 (permalink)  
Old 11-30-07, 11:17
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
What have you tried?
Post the SQL.
__________________
George
Twitter | Blog
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