By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,982 Members | 1,939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,982 IT Pros & Developers. It's quick & easy.

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

P: 98
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)

Expand|Select|Wrap|Line Numbers
  2. select substr(Class_Data, instr(Class_Data,'Fee-Value'),30) from  School where class='S013' and grade='A' and date ='20130301';
Apr 25 '13 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 10K+
P: 12,349
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.
Apr 25 '13 #2

P: 98
@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
Apr 26 '13 #3

Expert Mod 10K+
P: 12,349
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.
Apr 26 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.