Thread: partial string
View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 08:31 AM
Radoulov, Dimitre
 
Posts: n/a
Default Re: partial string


>>I have a text field in my database that contain a significant amount of
>>
>> text, where I just want to go through each row and delete from the
>> string everything between <body> and </body>.

[...]

> select
> substr(left(COLUMN,instr(COLUMN,'</body>')+length('</body>')-1),instr(COLUMN,'<body>'))
> from table;

[...]

Misread the post

So:

1. Backup your table.
2.

If you want to delete <body> ... </body>, tags included:

update TABLE set COLUMN=concat(left(COLUMN, instr(COLUMN,'<body>')-1),
substr(COLUMN, instr(COLUMN,'</body>')+length('</body>')));

or

If you want to delete <body> ... </body> and leave the tags:

update TABLE set COLUMN=concat(left(COLUMN,
instr(COLUMN,'<body>')+length('<body>')-1),
substr(COLUMN, instr(COLUMN,'</body>')));



Regards
Dimitre



Reply With Quote