开发者

how to escape or href in mysql query?

开发者 https://www.devze.com 2023-03-21 02:03 出处:网络
One of the field in my database contains data with some html tags say img, href. While querying I want to ignore those tags. If a tag contains href=\"foo.com\" th开发者_如何学JAVAen my search query fo

One of the field in my database contains data with some html tags say img, href. While querying I want to ignore those tags. If a tag contains href="foo.com" th开发者_如何学JAVAen my search query for foo in mysql should not brings the foo.com. It should ignore links, image links etc.


As far as I know, MySQL does not have any sort of built-in HTML parser and I doubt there's a simple way to write one.

My advice is to add a new column to the table with a plain text version of your HTML column and use it to perform searches. Whatever your server-side language is, it's likely to have a library to strip HTML tags. For instance, PHP has strip_tags().

0

精彩评论

暂无评论...
验证码 换一张
取 消