Forum Moderators: coopster

Message Too Old, No Replies

PHP's strip tags() equivalent MYSQL function

         

PHPycho

11:40 am on Jan 15, 2010 (gmt 0)

10+ Year Member




Hello forums!
I was just wondering to know how this can be accomplished:
Case:
[HIGHLIGHT="MySQL"]SELECT * FROM cms_pages WHERE body LIKE '%keywords%';[/HIGHLIGHT]
Problem: Suppose my keyword=font & body field contains:
<div style="font-size:12px">This is a body area</div>

then above query fetches this row.

I would like to know,
is there any function to strip the html tags while executing query?
something like:
[HIGHLIGHT="MySQL"]SELECT * FROM cms_pages WHERE strip_tags(body) LIKE '%keywords%';[/HIGHLIGHT]
or by any other means?

Thanks

rocknbil

10:05 pm on Jan 15, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, I don't think there is. Found nothing like that in string functions [dev.mysql.com].

However, if your pattern ins predictable, for example, always has an opening and closing div like you've posted, you can use mySQL regular expressions.