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
The above is the detailed content of How can I remove HTML tags from a MySQL database?. For more information, please follow other related articles on the PHP Chinese website!