首頁 >資料庫 >mysql教程 >如何從 MySQL 資料庫中刪除 HTML 標籤?

如何從 MySQL 資料庫中刪除 HTML 標籤?

Susan Sarandon
Susan Sarandon原創
2024-11-15 08:21:021001瀏覽

How can I remove HTML tags from a MySQL database?

MySQL Query to Remove HTML Tags

You have a substantial database filled with records containing HTML tags (). Removing these tags is essential. While PHP provides the strip_tags method, running a PHP script to modify all the records can be time-consuming.

MySQL Solution

MySQL version 5.5 and later offer XML functions that can address this issue:

SELECT ExtractValue(field, '//text()') FROM table;

This query extracts only the text content from the specified "field" column in the "table." It relies on the XML functions provided by MySQL to parse the HTML tags and retrieve the text content.

Reference

For more details on XML functions in MySQL, refer to the official documentation:
https://dev.mysql.com/doc/refman/5.5/en/xml-functions.html

以上是如何從 MySQL 資料庫中刪除 HTML 標籤?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn