I have table with field called description which contains text like following
|Description |
|----------------------------------
if you use php as your server side language you can use strip_tags function to remove tags.I hope it can help you.
In short, you can't, you need a more advanced language like PHP. Your SQL query is not the place to be doing string manipulation.
since this question is still in top google results, maybe the answer might help someone:
a quick function that replaces the content between two characters. It should work with words as well, but I haven't test it with words. For deleting in the following string: "this is a [demo]"
the string between [ and ] do:
select deletestr("this is a [demo]" ,'[',']');
and the function:
CREATE DEFINER=`replace_with_your_db`@`%`
FUNCTION `deletestr` (`inputstr` TEXT CHARSET utf8, `fromstr` VARCHAR(10) CHARSET utf8, `tostr` VARCHAR(10) CHARSET utf8) RETURNS text CHARSET utf8
NO SQL
RETURN
replace(inputstr,substr(inputstr, locate(fromstr,inputstr),locate(tostr,inputstr)-locate(fromstr,inputstr)+length(tostr)),'')
How about REPLACE() using a wildcard to capture the unknown text between opening and closing brackets? http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace