How to get all occurrence of a string in clob data in MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jagdeep gupta
    New Member
    • Aug 2010
    • 98

    How to get all occurrence of a string in clob data in MySQL

    I have one clob field 'Class_Data' in my table 'School' and in the clob there is one tag name as '<Fee-Value>' , I want to select the all occurrences of the tag from the clob data. I used the below query in mysql , but it select only the first occurrence of the tag(there are 12 occurrence of the vallue)

    Code:
     
    select substr(Class_Data, instr(Class_Data,'Fee-Value'),30) from  School where class='S013' and grade='A' and date ='20130301';
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    That's because instr only finds the first occurrence. You will probably have to use a stored procedure because I can't think of a way to continually iterate through the string and create rows with a standard query.

    Comment

    • jagdeep gupta
      New Member
      • Aug 2010
      • 98

      #3
      @Rabbit: Thanks for replying..

      I understood the that instr can not work, but the thing is in my environment using procedure is not allowed

      only few select queries I can use in my project

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        Without a stored procedure, it's next to impossible and very complex to accomplish. It's nigh impossible unless you know how many are in the string beforehand. And even if you know, it requires many embedded instr calls to pull them all out.

        Comment

        Working...