Results 1 to 8 of 8

Thread: Query problem

  1. #1
    Join Date
    Nov 2007
    Posts
    4

    Unanswered: 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 ?

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select '<me>wiqwn</me>' as i_found_it
      from daTable
     where thirdcolumn like '%<me>wiqwn</me>%'
    Attached Thumbnails Attached Thumbnails find-x.jpg  
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Nov 2007
    Posts
    4
    Hi

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

    Many thanks in advance.

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    See post 4 for the answer.
    Everything you need is there!
    George
    Home | Blog

  7. #7
    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

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What have you tried?
    Post the SQL.
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •